about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-27 14:18:20 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-27 14:18:20 +0200
commitf6db8d670e6055d1db83aed1dcda593beee37c67 (patch)
treec25e83b128c8f529dc322f1aa591407e0c7171af
parent0bbe2e436fc51df3091e28464dfac2f6d3bf5f38 (diff)
downloadnq-f6db8d670e6055d1db83aed1dcda593beee37c67.tar.gz
nq-f6db8d670e6055d1db83aed1dcda593beee37c67.tar.xz
nq-f6db8d670e6055d1db83aed1dcda593beee37c67.zip
nq: error handling for dup2
-rw-r--r--nq.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/nq.c b/nq.c
index 6fe739c..c5c7223 100644
--- a/nq.c
+++ b/nq.c
@@ -214,8 +214,11 @@ usage:
 
 	write_execline(lockfd, argc, argv);
 
-	dup2(lockfd, 2);
-	dup2(lockfd, 1);
+	if (dup2(lockfd, 2) < 0 ||
+	    dup2(lockfd, 1) < 0) {
+		perror("dup2");
+		exit(222);
+	}
 
 wait:
 	if ((tflag || wflag) && argc - optind > 0) {