This source file includes following definitions.
- opal_few
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include "opal_config.h"
21
22 #include <stdio.h>
23 #include <errno.h>
24 #ifdef HAVE_SYS_WAIT_H
25 #include <sys/wait.h>
26 #endif
27 #include <stdlib.h>
28 #ifdef HAVE_UNISTD_H
29 #include <unistd.h>
30 #endif
31
32 #include "opal/util/few.h"
33 #include "opal/util/basename.h"
34 #include "opal/util/argv.h"
35 #include "opal/constants.h"
36
37 int opal_few(char *argv[], int *status)
38 {
39 #if defined(HAVE_FORK) && defined(HAVE_EXECVE) && defined(HAVE_WAITPID)
40 pid_t pid, ret;
41
42 if ((pid = fork()) < 0) {
43 return OPAL_ERR_IN_ERRNO;
44 }
45
46
47
48 else if (0 == pid) {
49 execvp(argv[0], argv);
50 exit(errno);
51 }
52
53
54
55 else {
56 do {
57
58
59 if (pid == (ret = waitpid(pid, status, 0))) {
60 break;
61 }
62
63
64
65 else if (ret < 0) {
66 if (EINTR == errno) {
67 continue;
68 }
69
70
71
72 return OPAL_ERR_IN_ERRNO;
73 }
74 } while (true);
75 }
76
77
78
79 return OPAL_SUCCESS;
80 #else
81 return OPAL_ERR_NOT_SUPPORTED;
82 #endif
83 }