summary refs log tree commit diff
path: root/nq.c
diff options
context:
space:
mode:
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);