diff options
author | Denis Vlasenko | 2007-09-30 23:50:48 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-09-30 23:50:48 +0000 |
commit | 96e1b38586e80a0f014038bf4fdf4689c668fbd6 (patch) | |
tree | d7f6a7866700601598cfcc006b7dcb6cb4a7c07e /shell/hush.c | |
parent | deabacdf91c6d1c3cfcdb4cd06780807193de81d (diff) | |
download | busybox-96e1b38586e80a0f014038bf4fdf4689c668fbd6.zip busybox-96e1b38586e80a0f014038bf4fdf4689c668fbd6.tar.gz |
introduce and use close_on_exec_on(fd). -50 bytes.
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index 5f9f2c5..9c70556 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -760,9 +760,11 @@ static int builtin_eval(char **argv) static int builtin_cd(char **argv) { const char *newdir; - if (argv[1] == NULL) + if (argv[1] == NULL) { + // bash does nothing (exitcode 0) if HOME is ""; if it's unset, + // bash says "bash: cd: HOME not set" and does nothing (exitcode 1) newdir = getenv("HOME") ? : "/"; - else + } else newdir = argv[1]; if (chdir(newdir)) { printf("cd: %s: %s\n", newdir, strerror(errno)); @@ -3629,7 +3631,7 @@ static void setup_job_control(void) saved_task_pgrp = shell_pgrp = getpgrp(); debug_printf_jobs("saved_task_pgrp=%d\n", saved_task_pgrp); - fcntl(interactive_fd, F_SETFD, FD_CLOEXEC); + close_on_exec_on(interactive_fd); /* If we were ran as 'hush &', * sleep until we are in the foreground. */ |