add -f background option to dbclient

--HG--
extra : convert_revision : 5ef61c30c0a634ac0da22a8c694ce235690e8170
This commit is contained in:
Matt Johnston
2006-06-07 15:47:04 +00:00
parent be2b7d9725
commit c81e058bb0
4 changed files with 32 additions and 0 deletions

View File

@@ -212,6 +212,23 @@ static void cli_sessionloop() {
*/
case USERAUTH_SUCCESS_RCVD:
if (cli_opts.backgrounded) {
int devnull;
// keeping stdin open steals input from the terminal and
// is confusing, though stdout/stderr could be useful.
devnull = open(_PATH_DEVNULL, O_RDONLY);
if (devnull < 0) {
dropbear_exit("opening /dev/null: %d %s",
errno, strerror(errno));
}
dup2(devnull, STDIN_FILENO);
if (daemon(0, 1) < 0) {
dropbear_exit("Backgrounding failed: %d %s",
errno, strerror(errno));
}
}
#ifdef ENABLE_CLI_LOCALTCPFWD
setup_localtcp();
#endif