aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/other/oneit.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/other/oneit.c b/toys/other/oneit.c
index 8e4b7133..cc510c15 100644
--- a/toys/other/oneit.c
+++ b/toys/other/oneit.c
@@ -61,7 +61,10 @@ void oneit_main(void)
{
int i, pid, pipes[] = {SIGUSR1, SIGUSR2, SIGTERM, SIGINT};
- if (FLAG_3) {
+ // Setup signal handlers for signals of interest
+ for (i = 0; i<ARRAY_LEN(pipes); i++) xsignal(pipes[i], oneit_signaled);
+
+ if (toys.optflags & FLAG_3) {
// Ensure next available filehandle is #3
while (open("/", 0) < 3);
close(3);
@@ -70,9 +73,6 @@ void oneit_main(void)
fcntl(4, F_SETFD, FD_CLOEXEC);
}
- // Setup signal handlers for signals of interest
- for (i = 0; i<ARRAY_LEN(pipes); i++) xsignal(pipes[i], oneit_signaled);
-
while (!toys.signal) {
// Create a new child process.
@@ -83,7 +83,7 @@ void oneit_main(void)
// We ignore the return value of write (what would we do with it?)
// but save it in a variable we never read to make fortify shut up.
// (Real problem is if pid2 never reads, write() fills pipe and blocks.)
- while (pid != wait(&i)) if (FLAG_3) i = write(4, &pid, 4);
+ while (pid != wait(&i)) if (toys.optflags & FLAG_3) i = write(4, &pid, 4);
if (toys.optflags & FLAG_n) continue;
oneit_signaled((toys.optflags & FLAG_p) ? SIGUSR2 : SIGTERM);