version 1.44, 2017/07/12 09:24:17 |
version 1.45, 2017/07/12 10:04:51 |
|
|
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <paths.h> |
#include <paths.h> |
|
#include <signal.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <time.h> |
#include <time.h> |
|
|
char *cmd; |
char *cmd; |
int old_fd, pipe_fd[2], null_fd; |
int old_fd, pipe_fd[2], null_fd; |
struct format_tree *ft; |
struct format_tree *ft; |
|
sigset_t set, oldset; |
|
|
/* Destroy the old pipe. */ |
/* Destroy the old pipe. */ |
old_fd = wp->pipe_fd; |
old_fd = wp->pipe_fd; |
|
|
format_free(ft); |
format_free(ft); |
|
|
/* Fork the child. */ |
/* Fork the child. */ |
|
sigfillset(&set); |
|
sigprocmask(SIG_BLOCK, &set, &oldset); |
switch (fork()) { |
switch (fork()) { |
case -1: |
case -1: |
|
sigprocmask(SIG_SETMASK, &oldset, NULL); |
cmdq_error(item, "fork error: %s", strerror(errno)); |
cmdq_error(item, "fork error: %s", strerror(errno)); |
|
|
free(cmd); |
free(cmd); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
case 0: |
case 0: |
/* Child process. */ |
/* Child process. */ |
close(pipe_fd[0]); |
|
proc_clear_signals(server_proc); |
proc_clear_signals(server_proc); |
|
sigprocmask(SIG_SETMASK, &oldset, NULL); |
|
close(pipe_fd[0]); |
|
|
if (dup2(pipe_fd[1], STDIN_FILENO) == -1) |
if (dup2(pipe_fd[1], STDIN_FILENO) == -1) |
_exit(1); |
_exit(1); |
|
|
_exit(1); |
_exit(1); |
default: |
default: |
/* Parent process. */ |
/* Parent process. */ |
|
sigprocmask(SIG_SETMASK, &oldset, NULL); |
close(pipe_fd[1]); |
close(pipe_fd[1]); |
|
|
wp->pipe_fd = pipe_fd[0]; |
wp->pipe_fd = pipe_fd[0]; |