Changeset 513 for trunk/src/ocat.c
- Timestamp:
- 09/17/09 14:55:32 (3 years ago)
- File:
-
- 1 edited
-
trunk/src/ocat.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ocat.c
r511 r513 126 126 case 0: 127 127 log_msg(LOG_INFO, "process backgrounded by parent %d, new pid = %d", ppid, getpid()); 128 (void) umask(0); 129 if (setsid() == -1) 130 log_msg(LOG_ERR, "could not set process group ID: \"%s\"", strerror(errno)); 131 if (chdir("/") == -1) 132 log_msg(LOG_ERR, "could not change directory to /: \"%s\"", strerror(errno)); 133 // redirect standard files to /dev/null 134 if (!freopen( "/dev/null", "r", stdin)) 135 log_msg(LOG_ERR, "could not reconnect stdin to /dev/null: \"%s\"", strerror(errno)); 136 if (!freopen( "/dev/null", "w", stdout)) 137 log_msg(LOG_ERR, "could not reconnect stdout to /dev/null: \"%s\"", strerror(errno)); 138 if (!freopen( "/dev/null", "w", stderr)) 139 log_msg(LOG_ERR, "could not reconnect stderr to /dev/null: \"%s\"", strerror(errno)); 128 140 return; 129 141 … … 224 236 struct passwd *pwd, pwdm; 225 237 int urlconv = 0; 226 int nullfd;227 238 228 239 snprintf(def, 100, "127.0.0.1:%d", OCAT_LISTEN_PORT); … … 467 478 open_connect_log(pwd->pw_dir); 468 479 469 // reconnect stdio if logfile ok and daemonized470 if (CNF(daemon))471 {472 if ((nullfd = open("/dev/null", O_RDWR)) != -1)473 {474 oe_close(0);475 dup(nullfd);476 oe_close(1);477 dup(nullfd);478 oe_close(2);479 dup(nullfd);480 }481 else482 log_msg(LOG_ERR, "could not reconnect stdio to /dev/null: \"%s\"", strerror(errno));483 }484 485 480 // create socks connector thread and communication queue 486 481 if (pipe(CNF(socksfd)) == -1)
Note: See TracChangeset
for help on using the changeset viewer.
