aboutsummaryrefslogtreecommitdiffstats
path: root/scd/scdaemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'scd/scdaemon.c')
-rw-r--r--scd/scdaemon.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index acc5b4772..064cae9cb 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -871,9 +871,19 @@ main (int argc, char **argv )
/* Close stdin, stdout and stderr unless it is the log stream. */
for (i=0; i <= 2; i++)
{
- if ( log_test_fd (i) && i != fd)
- close (i);
+ if (!log_test_fd (i) && i != fd )
+ {
+ if ( !close (i)
+ && open ("/dev/null", i? O_WRONLY : O_RDONLY) == -1)
+ {
+ log_error ("failed to open '%s': %s\n",
+ "/dev/null", strerror (errno));
+ cleanup ();
+ exit (1);
+ }
+ }
}
+
if (setsid() == -1)
{
log_error ("setsid() failed: %s\n", strerror(errno) );