Mercurial > dropbear
diff cli-session.c @ 326:d965110e3f5c
add -f background option to dbclient
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 07 Jun 2006 15:47:04 +0000 |
parents | 0e4f225b7e07 |
children | c216212001fc |
line wrap: on
line diff
--- a/cli-session.c Wed Jun 07 15:01:20 2006 +0000 +++ b/cli-session.c Wed Jun 07 15:47:04 2006 +0000 @@ -212,6 +212,23 @@ */ 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