blob: 3af32701aecf20fbde67146a3b8991000508b777 [file] [log] [blame]
Brian Silvermanaf784862014-05-13 08:14:55 -07001#include <sys/wait.h>
Brian Silvermanf665d692013-02-17 22:11:39 -08002#include <sys/select.h>
3#include <stdlib.h>
Brian Silvermand169fcd2013-02-27 13:18:47 -08004#include <stdio.h>
Brian Silvermand169fcd2013-02-27 13:18:47 -08005#include <unistd.h>
6#include <sys/types.h>
7
8#include <string>
Brian Silvermanf665d692013-02-17 22:11:39 -08009
John Park398c74a2018-10-20 21:17:39 -070010#include "aos/init.h"
John Park33858a32018-09-28 23:05:48 -070011#include "aos/util/run_command.h"
brians343bc112013-02-10 01:53:46 +000012
Brian Silverman8070a222013-02-28 15:01:36 -080013// 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 Silvermanfe9b7a22014-02-10 15:03:42 -080015//
Brian Silverman6da04272014-05-18 18:47:48 -070016// Will also touch the file given as a first argument.
Brian Silverman8070a222013-02-28 15:01:36 -080017
Brian Silvermand169fcd2013-02-27 13:18:47 -080018int main(int argc, char **argv) {
brians343bc112013-02-10 01:53:46 +000019 aos::InitCreate();
Brian Silvermand169fcd2013-02-27 13:18:47 -080020
21 if (argc > 1) {
Brian Silvermanaf784862014-05-13 08:14:55 -070022 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 Silvermand169fcd2013-02-27 13:18:47 -080026 exit(EXIT_FAILURE);
27 }
28 }
29
brians343bc112013-02-10 01:53:46 +000030 select(0, NULL, NULL, NULL, NULL); // wait forever
31 aos::Cleanup();
32}