From f47b1b9abf446a9aeec5dc53d2bb9e0b125a4b86 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Mon, 3 Aug 2015 15:18:19 +0200 Subject: redirect stdout/stderr before waiting, else nq sleep 100; b=$(nq sleep 100) stalls --- nq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'nq.c') diff --git a/nq.c b/nq.c index ba8dc1c..fdae6c0 100644 --- a/nq.c +++ b/nq.c @@ -155,6 +155,7 @@ usage: dprintf(1, "%s\n", lockfile); close(0); close(1); + close(2); /* signal parent to exit. */ close(pipefd[1]); @@ -199,6 +200,9 @@ usage: write_execline(lockfd, argc, argv); + dup2(lockfd, 2); + dup2(lockfd, 1); + wait: if ((tflag || wflag) && argc - optind > 0) { /* wait for files passed as command line arguments. */ @@ -270,8 +274,6 @@ again: swrite(lockfd, "\n\n"); fchmod(lockfd, 0700); - dup2(lockfd, 2); - dup2(lockfd, 1); close(lockfd); setenv("NQJOBID", lockfile+1, 1); -- cgit 1.4.1