Skip to content

Commit 02ab507

Browse files
committed
Add prints
1 parent c9f20ea commit 02ab507

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

P1/shell.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ void execute_multiple_pipe_cmd(CMD_OPTS_REDIRECT ** cmds, size_t n_cmds) {
263263
if(cmds[n_cmds-1]->out_fd != 1)
264264
close(cmds[n_cmds-1]->out_fd);
265265
waitpid(child_cmd_pid, &status, 0);
266-
printf("******************************\n");
267-
printf("\nStatus of PID %d: %d\n\n", child_cmd_pid, status);
266+
if (cmds[n_cmds-1]->out_fd == 1 && cmds[n_cmds-1]->out_redirect_file == NULL)
267+
printf("******************************\n");
268+
printf("\nStatus of PID %d: %d\n", child_cmd_pid, status);
269+
printf("______________________________\n\n");
268270
}
269271
}
270272

@@ -299,6 +301,10 @@ void execute_double_pipe_cmd(CMD_OPTS_REDIRECT * in_cmd,
299301
int status;
300302
close(pipe_fd[0][1]);
301303
waitpid(child_cmd_pid, &status, 0);
304+
if (in_cmd->out_fd == 1 && in_cmd->out_redirect_file == NULL)
305+
printf("******************************\n");
306+
printf("\nStatus of PID %d: %d\n", child_cmd_pid, status);
307+
printf("______________________________\n\n");
302308
}
303309

304310
tee(pipe_fd[0][0], pipe_fd[1][1], INT_MAX, 0);
@@ -341,6 +347,10 @@ void execute_triple_pipe_cmd(CMD_OPTS_REDIRECT * in_cmd,
341347
int status;
342348
close(pipe_fd[0][1]);
343349
waitpid(child_cmd_pid, &status, 0);
350+
if (in_cmd->out_fd == 1 && in_cmd->out_redirect_file == NULL)
351+
printf("******************************\n");
352+
printf("\nStatus of PID %d: %d\n", child_cmd_pid, status);
353+
printf("______________________________\n\n");
344354
}
345355

346356
tee(pipe_fd[0][0], pipe_fd[1][1], INT_MAX, 0);

0 commit comments

Comments
 (0)