Skip to content

Commit

Permalink
test/pipes: don't use the shell_job option
Browse files Browse the repository at this point in the history
It's required to execute the test in Jenkins.
We need to stop using a current terminal. For that we need to
* create a new session
* redirect stdout and stderr in a file.
* close stdin

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
  • Loading branch information
avagin committed May 18, 2015
1 parent ac48b64 commit 6f92ded
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/pipes/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ char inh_file_arg[64];
char *dump_argv[] = {
"criu", "dump",
"-D", IMG_DIR, "-o", DUMP_LOG_FILE,
"-v4", "-j",
"-v4",
"-t", pid_number,
NULL
};
Expand All @@ -125,7 +125,7 @@ char *restore_argv[] = {
"criu", "restore", "-d",
"-D", IMG_DIR, "-o", RESTORE_LOG_FILE,
"--pidfile", RESTORE_PID_FILE,
"-v4", "-j",
"-v4",
inh_pipe_opt, inh_pipe_arg,
inh_file_opt, inh_file_arg,
NULL
Expand Down Expand Up @@ -162,6 +162,7 @@ void unlink_safe(char *pathname);
void execv_safe(char *path, char *argv[], int ls);
pid_t waitpid_safe(pid_t pid, int *status, int options, int id);
void prctl_safe(int option, ulong arg2, ulong arg3, ulong arg4, ulong arg5);
int dup2_safe(int oldfd, int newfd);

void usage(char *cmd)
{
Expand Down Expand Up @@ -227,10 +228,17 @@ int main(int argc, char *argv[])
/* child */
int dupfd = -1;
int openfd = -1;
int logfd;

child_pid = getpid();

close_safe(pipefd[READ_FD]);
setsid();
logfd = open_safe(OLD_LOG_FILE, O_WRONLY | O_APPEND | O_CREAT);
dup2_safe(logfd, 1);
dup2_safe(logfd, 2);
close(logfd);
close(0);

/* open a regular file and move it to CLASH_FD */
if (cflag)
Expand Down Expand Up @@ -457,12 +465,12 @@ void restore_child(int *new_pipefd, char *old_pipe_name)
snprintf(inh_file_arg, sizeof inh_file_arg,
"fd[%d]:%s", filefd, OLD_LOG_FILE + 1);

restore_argv[13] = inh_file_opt;
restore_argv[12] = inh_file_opt;
} else
restore_argv[13] = NULL;
restore_argv[11] = inh_pipe_opt;
restore_argv[12] = NULL;
restore_argv[10] = inh_pipe_opt;
} else
restore_argv[11] = NULL;
restore_argv[10] = NULL;

snprintf(buf, sizeof buf, "%s/%s", IMG_DIR, RESTORE_PID_FILE);
unlink_safe(buf);
Expand Down Expand Up @@ -572,7 +580,7 @@ int open_safe(char *pathname, int flags)
{
int fd;

if ((fd = open(pathname, flags)) == -1)
if ((fd = open(pathname, flags, 0777)) == -1)
die("open: pathname=%s", pathname);
return fd;
}
Expand Down

0 comments on commit 6f92ded

Please sign in to comment.