summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-23 01:59:09 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-23 01:59:09 +0800
commit85e551026c0b73f77ed38804c5785edb36481e2b (patch)
tree11f2c10aaca3ff02c74b27eed56644ef6f4ca05c
parent4404826b6a3baa886cace4a173ff61d72ccc20c2 (diff)
downloadpttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.tar
pttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.tar.gz
pttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.tar.bz2
pttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.tar.lz
pttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.tar.xz
pttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.tar.zst
pttbbs-85e551026c0b73f77ed38804c5785edb36481e2b.zip
redirect stderr(fd 2) to file.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3299 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/mbbsd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 722c059f..5de68ea1 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -81,8 +81,7 @@ start_daemon(void)
while (n)
close(--n);
- /* in2: open /dev/null to fd:2 */
- if( ((fd = open("/dev/null", O_WRONLY)) >= 0) && fd != 2 ){
+ if( ((fd = open("log/stderr", O_WRONLY | O_CREAT | O_APPEND, 0644)) >= 0) && fd != 2 ){
dup2(fd, 2);
close(fd);
}
@@ -1479,6 +1478,7 @@ main(int argc, char *argv[], char *envp[])
static int
shell_login(int argc, char *argv[], char *envp[])
{
+ int fd;
STATINC(STAT_SHELLLOGIN);
/* Give up root privileges: no way back from here */
@@ -1505,6 +1505,10 @@ shell_login(int argc, char *argv[], char *envp[])
}
close(2);
/* don't close fd 1, at least init_tty need it */
+ if( ((fd = open("log/stderr", O_WRONLY | O_CREAT | O_APPEND, 0644)) >= 0) && fd != 2 ){
+ dup2(fd, 2);
+ close(fd);
+ }
init_tty();
if (check_ban_and_load(0)) {