]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blobdiff - src/coloredstderr.c
fcntl(): Don't call dup_fd() if real_fcntl() failed.
[coloredstderr/coloredstderr.git] / src / coloredstderr.c
index dbcfd235cf649a7a412b6f1ca6f896c1bbf71c71..b2ef2975ef8d6e5ffae8625e925ae5caf46e3523 100644 (file)
@@ -280,7 +280,7 @@ int fcntl(int fd, int cmd, int arg) {
 
     result = real_fcntl(fd, cmd, arg);
     /* We only care about duping fds. */
-    if (cmd == F_DUPFD) {
+    if (cmd == F_DUPFD && result != -1) {
         int saved_errno = errno;
         dup_fd(fd, result);
         errno = saved_errno;