/bin/sh question

From: Dmitry Sivachenko (mitya_at_cavia.pp.ru)
Date: 04/30/04

  • Next message: Martin Moeller: "Accessing (the i4b) device driver"
    Date: Fri, 30 Apr 2004 15:28:29 +0400
    To: hackers@freebsd.org
    
    

    Hello!

    We use recent -STABLE.
    We observed /bin/sh looping forever executing a script.
    We run this script with -T option to sh(1).
    When sh(1) receives a HUP, we entering our trap handler which spawns
    child process. When this process exits, sh(1) loops.

    The backtrace is the following:

    (gdb) bt
    #0 0x80763fc in wait4 ()
    #1 0x8075941 in wait3 ()
    #2 0x8051f8a in waitproc (block=1, status=0xbfbffa0c)
        at /mnt/backup/releng_4/src/bin/sh/jobs.c:1025
    #3 0x8051cbd in dowait (block=1, job=0x80c6000)
        at /mnt/backup/releng_4/src/bin/sh/jobs.c:926
    #4 0x8051b8a in waitforjob (jp=0x80c6000, origstatus=0xbfbffa88)
        at /mnt/backup/releng_4/src/bin/sh/jobs.c:870
    #5 0x804be33 in evalcommand (cmd=0x80b6d6c, flags=0, backcmd=0x0)
        at /mnt/backup/releng_4/src/bin/sh/eval.c:904
    #6 0x804acc0 in evaltree (n=0x80b6d6c, flags=0)
        at /mnt/backup/releng_4/src/bin/sh/eval.c:281
    #7 0x804aafa in evaltree (n=0x80b6e04, flags=0)
        at /mnt/backup/releng_4/src/bin/sh/eval.c:199
    #8 0x804aafa in evaltree (n=0x80b6e38, flags=0)
        at /mnt/backup/releng_4/src/bin/sh/eval.c:199
    #9 0x804aa73 in evalstring (
        s=0x80c5100 "rm -f /tmp/st28742.box221.zecke.demos.su; _clean SIGHUP /dev/tt
    yph.28742.zecke.demos.su 28742; exit")
        at /mnt/backup/releng_4/src/bin/sh/eval.c:171
    #10 0x80598da in dotrap () at /mnt/backup/releng_4/src/bin/sh/trap.c:401
    #11 0x804acf6 in evaltree (n=0x80b6d00, flags=0)
        at /mnt/backup/releng_4/src/bin/sh/eval.c:290
    #12 0x80528f4 in cmdloop (top=1) at /mnt/backup/releng_4/src/bin/sh/main.c:250

    The waitproc() at jobs.c:926 returns -1 and sets errno to ECHILD (because
    the child does not exist at that time).
    Since (pid <= 0) condition is true at jobs.c:935, -1 is returned and we are
    entering dotrap() at jobs.c:870. dotrap() never alters (struct job *)state.

    So we get an infinite loop around jobs.c:869.

    Unfortunatelly I can't provide a simple enough how-to-observe script for
    this, but the above logic seems weird for me. I can provide additional
    details or coredump if needed.
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Martin Moeller: "Accessing (the i4b) device driver"

    Relevant Pages

    • Problem with Find and Tables
      ... I've made a script that search all words of a specified style. ... This macro works fine but enter in an infinite loop when it find a text ... Set appWord = Wscript.CreateObject ...
      (microsoft.public.word.vba.general)
    • Re: Is inifinite loop not a good practice?
      ... I have to write a python script that would continously monitor and process a queue database. ... Once the script sees an unprocessed record it will create a thread to process it otherwise it will do nothing. ... I've been planning to do an infinite loop within the script to do this but I've been hearing comments that infinite loop is a bad programming practice. ...
      (comp.lang.python)
    • Re: Stop PHP utterly!
      ... > I made a typo and got caught in an infinite loop. ... > the execution time expires and fix the script but this time it kept going ... > I finally just rebooted the server! ...
      (alt.php)
    • Re: Stop PHP utterly!
      ... > I made a typo and got caught in an infinite loop. ... > the execution time expires and fix the script but this time it kept going ... > I finally just rebooted the server! ...
      (comp.lang.php)
    • Re: While read and "too many open files" problem.
      ... : On 7 Mar, 12:37, Bruce Barnett ... :> You have a potentially infinite loop reading the same file over and over ... script is continually scanning the log file for new entries. ...
      (comp.unix.shell)