Brian Silverman | af78486 | 2014-05-13 08:14:55 -0700 | [diff] [blame] | 1 | #include <sys/wait.h> |
Brian Silverman | f665d69 | 2013-02-17 22:11:39 -0800 | [diff] [blame] | 2 | #include <sys/select.h> |
| 3 | #include <stdlib.h> |
Brian Silverman | d169fcd | 2013-02-27 13:18:47 -0800 | [diff] [blame] | 4 | #include <stdio.h> |
Brian Silverman | d169fcd | 2013-02-27 13:18:47 -0800 | [diff] [blame] | 5 | #include <unistd.h> |
| 6 | #include <sys/types.h> |
| 7 | |
| 8 | #include <string> |
Brian Silverman | f665d69 | 2013-02-17 22:11:39 -0800 | [diff] [blame] | 9 | |
John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 10 | #include "aos/init.h" |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 11 | #include "aos/util/run_command.h" |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 12 | |
Brian Silverman | 8070a22 | 2013-02-28 15:01:36 -0800 | [diff] [blame] | 13 | // Initializes shared memory. This is the only file that will create the shared |
| 14 | // memory file if it doesn't already exist (and set everything up). |
Brian Silverman | fe9b7a2 | 2014-02-10 15:03:42 -0800 | [diff] [blame] | 15 | // |
Brian Silverman | 6da0427 | 2014-05-18 18:47:48 -0700 | [diff] [blame] | 16 | // Will also touch the file given as a first argument. |
Brian Silverman | 8070a22 | 2013-02-28 15:01:36 -0800 | [diff] [blame] | 17 | |
Brian Silverman | d169fcd | 2013-02-27 13:18:47 -0800 | [diff] [blame] | 18 | int main(int argc, char **argv) { |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 19 | aos::InitCreate(); |
Brian Silverman | d169fcd | 2013-02-27 13:18:47 -0800 | [diff] [blame] | 20 | |
| 21 | if (argc > 1) { |
Brian Silverman | af78486 | 2014-05-13 08:14:55 -0700 | [diff] [blame] | 22 | const int result = ::aos::util::RunCommand( |
| 23 | (std::string("touch '") + argv[1] + "'").c_str()); |
| 24 | if (result == -1 || !WIFEXITED(result) || WEXITSTATUS(result) != 0) { |
| 25 | fprintf(stderr, "`touch '%s'` failed; result = %x\n", argv[1], result); |
Brian Silverman | d169fcd | 2013-02-27 13:18:47 -0800 | [diff] [blame] | 26 | exit(EXIT_FAILURE); |
| 27 | } |
| 28 | } |
| 29 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 30 | select(0, NULL, NULL, NULL, NULL); // wait forever |
| 31 | aos::Cleanup(); |
| 32 | } |