=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/tmux/server.c 2009/06/25 22:09:20 1.4 --- src/usr.bin/tmux/server.c 2009/06/26 22:12:19 1.5 *************** *** 1,4 **** ! /* $OpenBSD: server.c,v 1.4 2009/06/25 22:09:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server.c,v 1.5 2009/06/26 22:12:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 25,30 **** --- 25,31 ---- #include #include + #include #include #include #include *************** *** 131,137 **** int server_start(char *path) { ! int pair[2], srv_fd; char *cause; char rpathbuf[MAXPATHLEN]; --- 132,138 ---- int server_start(char *path) { ! int pair[2], srv_fd, null_fd; char *cause; char rpathbuf[MAXPATHLEN]; *************** *** 175,180 **** --- 176,193 ---- exit(1); } logfile("server"); + + /* + * Close stdin/stdout/stderr. Can't let daemon() do this as they are + * needed until now to print configuration file errors. + */ + if ((null_fd = open(_PATH_DEVNULL, O_RDWR)) != -1) { + dup2(null_fd, STDIN_FILENO); + dup2(null_fd, STDOUT_FILENO); + dup2(null_fd, STDERR_FILENO); + if (null_fd > 2) + close(null_fd); + } log_debug("server started, pid %ld", (long) getpid()); log_debug("socket path %s", socket_path);