devel: Builtin wait infinite loop when SIGINT received

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

devel: Builtin wait infinite loop when SIGINT received

Eduardo A. Bustamante López
There's something weird about the wait builtin + SIGINT handling in the latest
`devel' branch (i.e. 6374eecf232e70e45fe9c49cc8335e8779c07979)

If you interrupt the second `wait' with C-c, the shell will go into an infinite
loop.

  dualbus@debian:~/src/gnu/bash-builds/devel$ cat /tmp/s
  #!/bin/bash
  : &
  wait
  sleep inf &
  wait

  dualbus@debian:~/src/gnu/bash-builds/devel$ ./bash -x /tmp/s
  + wait
  + :
  + wait
  + sleep inf
  ^C^Z
  [1]+  Stopped                 ./bash -x /tmp/s
  dualbus@debian:~/src/gnu/bash-builds/devel$ kill -6 %%
 
  [1]+  Stopped                 ./bash -x /tmp/s
  dualbus@debian:~/src/gnu/bash-builds/devel$ fg
  ./bash -x /tmp/s
  Aborted (core dumped)

(I suspended the process and killed it with SIGABRT to get a nice stack trace).

  Core was generated by `./bash -x /tmp/s'.
  Program terminated with signal SIGABRT, Aborted.
  #0  wait_sigint_handler (sig=2) at ../../bash/jobs.c:2527
  2527    {
  (gdb) bt
  #0  wait_sigint_handler (sig=2) at ../../bash/jobs.c:2527
  #1  <signal handler called>
  #2  0x00007fcbc52e4fba in __GI___waitpid (pid=-1, stat_loc=0x7ffc4d9ec21c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
  #3  0x0000563ed5620317 in waitchld (wpid=8312, block=1) at ../../bash/jobs.c:3566
  #4  0x0000563ed561e6a7 in wait_for (pid=8312) at ../../bash/jobs.c:2772
  #5  0x0000563ed561db90 in wait_for_single_pid (pid=8312, flags=1) at ../../bash/jobs.c:2393
  #6  0x0000563ed561df8b in wait_for_background_pids () at ../../bash/jobs.c:2461
  #7  0x0000563ed5678220 in wait_builtin (list=0x0) at ../../../bash/builtins/../../../bash/builtins/wait.def:171
  #8  0x0000563ed5609ad2 in execute_builtin (builtin=0x563ed56780c7 <wait_builtin>, words=0x563ed6ec7b48, flags=0, subshell=0) at ../../bash/execute_cmd.c:4609
  #9  0x0000563ed560aa32 in execute_builtin_or_function (words=0x563ed6ec7b48, builtin=0x563ed56780c7 <wait_builtin>, var=0x0, redirects=0x0, fds_to_close=0x563ed6ec3e08, flags=0)
      at ../../bash/execute_cmd.c:5107
  #10 0x0000563ed56093b4 in execute_simple_command (simple_command=0x563ed6ec7a08, pipe_in=-1, pipe_out=-1, async=0, fds_to_close=0x563ed6ec3e08) at ../../bash/execute_cmd.c:4395
  #11 0x0000563ed5602ac8 in execute_command_internal (command=0x563ed6ec7ec8, asynchronous=0, pipe_in=-1, pipe_out=-1, fds_to_close=0x563ed6ec3e08) at ../../bash/execute_cmd.c:811
  #12 0x0000563ed5601fe4 in execute_command (command=0x563ed6ec7ec8) at ../../bash/execute_cmd.c:393
  #13 0x0000563ed55eb51c in reader_loop () at ../../bash/eval.c:172
  #14 0x0000563ed55e8fd1 in main (argc=3, argv=0x7ffc4d9ecb38, env=0x7ffc4d9ecb58) at ../../bash/shell.c:794

--
Eduardo Bustamante
https://dualbus.me/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: devel: Builtin wait infinite loop when SIGINT received

Chet Ramey
On 6/20/17 1:06 AM, Eduardo A. Bustamante López wrote:
> There's something weird about the wait builtin + SIGINT handling in the latest
> `devel' branch (i.e. 6374eecf232e70e45fe9c49cc8335e8779c07979)

Well, that comment in the code certainly proved out. Thanks for the report.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://cnswww.cns.cwru.edu/~chet/

Loading...