5 // Created by Chris Suter on 8/12/15.
16 #include "test-utils.h"
18 int __attribute__((sentinel
)) systemx(const char *prog
, ...)
24 const char **parg
= args
;
26 *parg
++ = basename((char *)prog
);
32 while ((*parg
= va_arg(ap
, char *))) {
33 if (*parg
== SYSTEMX_QUIET
) {
41 posix_spawn_file_actions_t facts
, *pfacts
= NULL
;
44 posix_spawn_file_actions_init(&facts
);
45 posix_spawn_file_actions_addopen(&facts
, STDOUT_FILENO
, "/dev/null", O_APPEND
, 0);
50 assert_no_err(posix_spawn(&pid
, prog
, pfacts
, NULL
, (char * const *)args
, NULL
));
53 posix_spawn_file_actions_destroy(pfacts
);
56 assert(ignore_eintr(waitpid(pid
, &status
, 0), -1) == pid
);
58 if (WIFEXITED(status
))
59 return WEXITSTATUS(status
);