Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2015-10-28 12:01:11 +00:00
19 changed files with 125 additions and 101 deletions

18
job.c
View File

@ -44,22 +44,22 @@ job_run(const char *cmd, struct session *s, int cwd,
void (*callbackfn)(struct job *), void (*freefn)(void *), void *data)
{
struct job *job;
struct environ env;
struct environ *env;
pid_t pid;
int nullfd, out[2];
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
return (NULL);
environ_init(&env);
environ_copy(&global_environ, &env);
env = environ_create();
environ_copy(global_environ, env);
if (s != NULL)
environ_copy(&s->environ, &env);
server_fill_environ(s, &env);
environ_copy(s->environ, env);
server_fill_environ(s, env);
switch (pid = fork()) {
case -1:
environ_free(&env);
environ_free(env);
close(out[0]);
close(out[1]);
return (NULL);
@ -69,8 +69,8 @@ job_run(const char *cmd, struct session *s, int cwd,
if (cwd != -1 && fchdir(cwd) != 0)
chdir("/");
environ_push(&env);
environ_free(&env);
environ_push(env);
environ_free(env);
if (dup2(out[1], STDIN_FILENO) == -1)
fatal("dup2 failed");
@ -95,7 +95,7 @@ job_run(const char *cmd, struct session *s, int cwd,
}
/* parent */
environ_free(&env);
environ_free(env);
close(out[1]);
job = xmalloc(sizeof *job);