This source file includes following definitions.
- main
1
2
3
4
5
6
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <errno.h>
12 #include <spawn.h>
13
14 #include "opal/util/argv.h"
15
16 int main(int argc, char* argv[])
17 {
18 int rc;
19 char **pargv = NULL;
20 pid_t pid;
21 posix_spawn_file_actions_t factions;
22 posix_spawnattr_t attrs;
23
24 rc = posix_spawnattr_init(&attrs);
25 if (0 != rc) {
26 fprintf(stderr, "ERROR INIT ATTRS: %d\n", errno);
27 exit(1);
28 }
29
30 rc = posix_spawn_file_actions_init(&factions);
31 if (0 != rc) {
32 fprintf(stderr, "ERROR INIT FACTIONS: %d\n", errno);
33 exit(1);
34 }
35 posix_spawn_file_actions_addclose(&factions, fileno(stdin));
36
37 opal_argv_append_nosize(&pargv, "hostname");
38
39 rc = posix_spawn(&pid, "/usr/bin/hostname", NULL, NULL, pargv, NULL);
40 posix_spawn_file_actions_destroy(&factions);
41 posix_spawnattr_destroy(&attrs);
42
43 sleep(1);
44 return 0;
45 }