|
|
const char * const prg, const char * const info) | const char * const prg, const char * const info) |
{ | { |
struct stat st; | struct stat st; |
|
pid_t command_child; |
|
|
if (command == NULL || *command == 0 || | if (command == NULL || *command == 0 || |
stat(command, &st) < 0 || !S_ISREG(st.st_mode)) { | stat(command, &st) < 0 || !S_ISREG(st.st_mode)) { |
fprintf(stderr, "Unable to launch [%s]\n", | fprintf(stderr, "Unable to launch [%s]\n", |
|
|
if (command_child == (pid_t) 0) { | if (command_child == (pid_t) 0) { |
execl(command, command, date, prg, info, NULL); | execl(command, command, date, prg, info, NULL); |
_exit(EXIT_FAILURE); | _exit(EXIT_FAILURE); |
} else if (command_child != (pid_t) -1) { |
} |
while (command_child != (pid_t) 0) { |
if (command_child == (pid_t) -1) { |
pause(); |
fprintf(stderr, "Unable to launch [%s] : [%s]\n", |
} |
command == NULL ? "null" : command, strerror(errno)); |
|
return -1; |
} | } |
return 0; | return 0; |
} | } |
|
|
if (pid == child) { | if (pid == child) { |
fprintf(stderr, "Klog child [%u] died\n", (unsigned) pid); | fprintf(stderr, "Klog child [%u] died\n", (unsigned) pid); |
should_exit = 1; | should_exit = 1; |
} else if (pid == command_child) { |
|
command_child = (pid_t) 0; |
|
} | } |
} | } |
#else | #else |
|
|
if (pid == child) { | if (pid == child) { |
fprintf(stderr, "Klog child [%u] died\n", (unsigned) pid); | fprintf(stderr, "Klog child [%u] died\n", (unsigned) pid); |
should_exit = 1; | should_exit = 1; |
} else if (pid == command_child) { |
|
command_child = (pid_t) 0; |
|
} | } |
} | } |
#endif | #endif |