Skip to content

Commit 6f92ded

Browse files
committed
test/pipes: don't use the shell_job option
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 <[email protected]> Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent ac48b64 commit 6f92ded

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/pipes/pipe.c

+15-7
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ char inh_file_arg[64];
116116
char *dump_argv[] = {
117117
"criu", "dump",
118118
"-D", IMG_DIR, "-o", DUMP_LOG_FILE,
119-
"-v4", "-j",
119+
"-v4",
120120
"-t", pid_number,
121121
NULL
122122
};
@@ -125,7 +125,7 @@ char *restore_argv[] = {
125125
"criu", "restore", "-d",
126126
"-D", IMG_DIR, "-o", RESTORE_LOG_FILE,
127127
"--pidfile", RESTORE_PID_FILE,
128-
"-v4", "-j",
128+
"-v4",
129129
inh_pipe_opt, inh_pipe_arg,
130130
inh_file_opt, inh_file_arg,
131131
NULL
@@ -162,6 +162,7 @@ void unlink_safe(char *pathname);
162162
void execv_safe(char *path, char *argv[], int ls);
163163
pid_t waitpid_safe(pid_t pid, int *status, int options, int id);
164164
void prctl_safe(int option, ulong arg2, ulong arg3, ulong arg4, ulong arg5);
165+
int dup2_safe(int oldfd, int newfd);
165166

166167
void usage(char *cmd)
167168
{
@@ -227,10 +228,17 @@ int main(int argc, char *argv[])
227228
/* child */
228229
int dupfd = -1;
229230
int openfd = -1;
231+
int logfd;
230232

231233
child_pid = getpid();
232234

233235
close_safe(pipefd[READ_FD]);
236+
setsid();
237+
logfd = open_safe(OLD_LOG_FILE, O_WRONLY | O_APPEND | O_CREAT);
238+
dup2_safe(logfd, 1);
239+
dup2_safe(logfd, 2);
240+
close(logfd);
241+
close(0);
234242

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

460-
restore_argv[13] = inh_file_opt;
468+
restore_argv[12] = inh_file_opt;
461469
} else
462-
restore_argv[13] = NULL;
463-
restore_argv[11] = inh_pipe_opt;
470+
restore_argv[12] = NULL;
471+
restore_argv[10] = inh_pipe_opt;
464472
} else
465-
restore_argv[11] = NULL;
473+
restore_argv[10] = NULL;
466474

467475
snprintf(buf, sizeof buf, "%s/%s", IMG_DIR, RESTORE_PID_FILE);
468476
unlink_safe(buf);
@@ -572,7 +580,7 @@ int open_safe(char *pathname, int flags)
572580
{
573581
int fd;
574582

575-
if ((fd = open(pathname, flags)) == -1)
583+
if ((fd = open(pathname, flags, 0777)) == -1)
576584
die("open: pathname=%s", pathname);
577585
return fd;
578586
}

0 commit comments

Comments
 (0)