[Pcsclite-cvs-commit] r6446 - /trunk/PCSC/src/pcscdaemon.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Fri Aug 24 09:07:19 UTC 2012
Author: rousseau
Date: Fri Aug 24 09:07:18 2012
New Revision: 6446
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6446
Log:
Fix redirection of stdin, stdout and stderr to /dev/null
The file descriptors for stdin, stdout and stderr were closed so any
library (like libusb) sending debug log to stderr was confusing pcscd
since file descriptor 2 (ex stderr) was re-used for something else.
Now the file descriptor 3 is really redirected to /dev/null
Modified:
trunk/PCSC/src/pcscdaemon.c
Modified: trunk/PCSC/src/pcscdaemon.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/pcscdaemon.c?rev=6446&op=diff
==============================================================================
--- trunk/PCSC/src/pcscdaemon.c (original)
+++ trunk/PCSC/src/pcscdaemon.c Fri Aug 24 09:07:18 2012
@@ -406,6 +406,7 @@
if (!setToForeground)
{
int pid;
+ int fd;
if (pipe(pipefd) == -1)
{
@@ -422,9 +423,17 @@
/* like in daemon(3): redirect standard input, standard output
* and standard error to /dev/null */
- (void)close(0);
- (void)close(1);
- (void)close(2);
+ fd = open("/dev/null", O_RDWR);
+ if (fd != -1)
+ {
+ dup2(fd, STDIN_FILENO);
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+
+ /* do not close stdin, stdout or stderr */
+ if (fd > 2)
+ close(fd);
+ }
if (pid)
/* in the father */
More information about the Pcsclite-cvs-commit
mailing list