about summary refs log tree commit diff
path: root/nq.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-03 15:18:19 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-03 15:18:19 +0200
commitf47b1b9abf446a9aeec5dc53d2bb9e0b125a4b86 (patch)
tree5597b6e9a4393c06b871748b0fa100a328a0618f /nq.c
parent91dae7a9bcc0a73fe684d9def8ca6224c5de0213 (diff)
downloadnq-f47b1b9abf446a9aeec5dc53d2bb9e0b125a4b86.tar.gz
nq-f47b1b9abf446a9aeec5dc53d2bb9e0b125a4b86.tar.xz
nq-f47b1b9abf446a9aeec5dc53d2bb9e0b125a4b86.zip
redirect stdout/stderr before waiting, else nq sleep 100; b=$(nq sleep 100) stalls
Diffstat (limited to 'nq.c')
-rw-r--r--nq.c6
1 files changed, 4 insertions, 2 deletions
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);