fputs(" -I, --parameters <factory> list parameters the factory takes\n", out);
fputs(" -r, --comm <name> rename self\n", out);
fputs(" -q, --quiet don't print pid(s)\n", out);
+ fputs(" -X, --dont-monitor-stdin don't monitor stdin when pausing\n", out);
fputs(" -c, --dont-pause don't pause after making fd(s)\n", out);
fputs("\n", out);
}
#endif
-static void wait_event(void)
+static void wait_event(bool monitor_stdin)
{
fd_set readfds;
sigset_t sigset;
int n = 0;
FD_ZERO(&readfds);
- /* Monitor the standard input only when the process
- * is in foreground. */
- if (tcgetpgrp(STDIN_FILENO) == getpgrp()) {
+ if (monitor_stdin) {
n = 1;
FD_SET(0, &readfds);
}
bool quiet = false;
bool cont = false;
void *data;
+ bool monitor_stdin = true;
static const struct option longopts[] = {
{ "list", no_argument, NULL, 'l' },
{ "parameters", required_argument, NULL, 'I' },
{ "comm", required_argument, NULL, 'r' },
{ "quiet", no_argument, NULL, 'q' },
+ { "dont-monitor-stdin", no_argument, NULL, 'X' },
{ "dont-puase", no_argument, NULL, 'c' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 },
};
- while ((c = getopt_long(argc, argv, "lhqcI:r:", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "lhqcI:r:X", longopts, NULL)) != -1) {
switch (c) {
case 'h':
usage(stdout, EXIT_SUCCESS);
case 'r':
rename_self(optarg);
break;
+ case 'X':
+ monitor_stdin = false;
+ break;
default:
usage(stderr, EXIT_FAILURE);
}
}
if (!cont)
- wait_event();
+ wait_event(monitor_stdin);
for (int i = 0; i < factory->N + factory->EX_N; i++)
if (fdescs[i].fd >= 0 && fdescs[i].close)
ts_finalize "failed in creating a fifo"
fi
- "$TS_HELPER_MKFDS" tcp 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
+ "$TS_HELPER_MKFDS" -X tcp 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
if ! read PID0 < "${FIFO}"; then
rm "${FIFO}"
ts_finalize "$TS_HELPER_MKFDS tcp...doesn't report its pid"
fi
- "$TS_HELPER_MKFDS" tcp6 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
+ "$TS_HELPER_MKFDS" -X tcp6 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
if ! read PID1 < "${FIFO}"; then
kill -CONT "${PID0}"
wait "${PID0}"
ts_finalize "$TS_HELPER_MKFDS tcp6...doesn't report its pid"
fi
- "$TS_HELPER_MKFDS" ro-regular-file 3 file=/etc/passwd > "${FIFO}" &
+ "$TS_HELPER_MKFDS" -X ro-regular-file 3 file=/etc/passwd > "${FIFO}" &
if ! read PID2 < "${FIFO}"; then
kill -CONT "${PID0}" "${PID1}"
wait "${PID0}" "${PID1}"
ts_finalize "$TS_HELPER_MKFDS ro-regular-file...doesn't report its pid"
fi
- "$TS_HELPER_MKFDS" udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
+ "$TS_HELPER_MKFDS" -X udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
if ! read PID3 < "${FIFO}"; then
kill -CONT "${PID0}" "${PID1}" "${PID2}"
wait "${PID0}" "${PID1}" "${PID2}"
ts_finalize "$TS_HELPER_MKFDS udp...doesn't report its pid"
fi
- "$TS_HELPER_MKFDS" udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
+ "$TS_HELPER_MKFDS" -X udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
if ! read PID4 < "${FIFO}"; then
kill -CONT "${PID0}" "${PID1}" "${PID2}" "${PID3}"
wait "${PID0}" "${PID1}" "${PID2}" "${PID3}"