(gdb) n
758 stop_pipeline (asynchronous, (COMMAND *)NULL);
(gdb) n
760 if (asynchronous)
(gdb) n
775 exec_result = wait_for (last_made_pid);
(gdb) n
_
父进程执行到这里开始等待子进程返回。
而子进程被我们停在了pipe_read函数的
while (read (pp[0], &ch, 1) == -1 && errno == EINTR)
这里,下面,我们要调试子进程,直到返回到父进程为止。
(gdb) bt
#0 0x00007ffff76cea30 in __read_nocancel () from /lib64/libc.so.6
#1 0x0000000000440f23 in pipe_read (pp=0x6e0de4 <pgrp_pipe>) at jobs.c:4245
#2 make_child (command=0xab02e8 "ls --color=auto", async_p=async_p@entry=0) at jobs.c:1818
#3 0x00000000004307a5 in execute_disk_command (cmdflags=0, fds_to_close=0xaae3c8, async=0, pipe_out=-1, pipe_in=-1,
command_line=0xaae2e8 "ls --color=auto", redirects=0x0, words=<optimized out>) at execute_cmd.c:4683
#4 execute_simple_command (simple_command=<optimized out>, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
async=async@entry=0, fds_to_close=fds_to_close@entry=0xaae3c8) at execute_cmd.c:3990
#5 0x0000000000431e9e in execute_command_internal (command=0xa98808, asynchronous=0, pipe_in=-1, pipe_out=-1,
fds_to_close=0xaae3c8) at execute_cmd.c:735
#6 0x000000000043342e in execute_command (command=0xa98808) at execute_cmd.c:382
#7 0x000000000041e253 in reader_loop () at eval.c:152
#8 0x000000000041c88e in main (argc=1, argv=0x7fffffffe2a8, env=0x7fffffffe2b8) at shell.c:749
(gdb) fini
Run till exit from #0 0x00007ffff76cea30 in __read_nocancel () from /lib64/libc.so.6
0x0000000000440f23 in pipe_read (pp=0x6e0de4 <pgrp_pipe>) at jobs.c:4245
4245 while (read (pp[0], &ch, 1) == -1 && errno == EINTR)
(gdb)
#if defined (PGRP_PIPE)
if (pipeline_pgrp == mypid)
pipe_read (pgrp_pipe);
#endif
}
else /* Without job control... */
{
if (pipeline_pgrp == 0)
pipeline_pgrp = shell_pgrp;
/* If these signals are set to SIG_DFL, we encounter the curious
situation of an interactive ^Z to a running process *working*
and stopping the process, but being unable to do anything with
that process to change its state. On the other hand, if they
are set to SIG_IGN, jobs started from scripts do not stop when
the shell running the script gets a SIGTSTP and stops. */
default_tty_job_signals ();
}
#if defined (PGRP_PIPE)
/* Release the process group pipe, since our call to setpgid ()
is done. The last call to sh_closepipe is done in stop_pipeline. */
sh_closepipe (pgrp_pipe);
#endif /* PGRP_PIPE */