Ask a Question related to Sun Solaris, Design and Development.

  1. #1

    Default Dealing with SIGHUP


    I recently read a mailing list 'posting' that claimed that if
    one typed

    (program arguments) </dev/null >> stdout 2>>stderr &

    that the resulting program would not die from a SIGHUP when the user
    initiating the program logged off.

    Is that the general case in some/most/all shells?

    I thought that to prevent SIGHUPs from killing your shell, you either
    had to invoke the command using nohup, write SIGHUP handling code
    yourself (assuming the shell allows it), or add code to the application to do
    the SIGHUP handling
    --
    The Tenth Annual Tcl/Tk Conference <URL: [url]http://www.tcl.tk/community/tcl2003[/url] >
    Even if explicitly stated to the contrary, nothing in this posting
    should be construed as representing my employer's opinions.
    <URL: mailto:lvirden@yahoo.com > <URL: [url]http://www.purl.org/NET/lvirden/[/url] >
    lvirden@yahoo.com Guest

  2. Similar Questions and Discussions

    1. #14870 [Fbk]: Some modules break SIGUSR1 and SIGHUP
      ID: 14870 Updated by: sniper@php.net Reported By: msopacua at idg dot nl Status: Feedback Bug Type: ...
    2. #14870 [Fbk->Opn]: Some modules break SIGUSR1 and SIGHUP
      ID: 14870 Updated by: msopacua@php.net Reported By: msopacua at idg dot nl -Status: Feedback +Status: ...
    3. #14870 [Opn->Fbk]: Some modules break SIGUSR1 and SIGHUP
      ID: 14870 Updated by: sniper@php.net Reported By: msopacua at idg dot nl -Status: Open +Status: ...
    4. #14870 [NoF->Opn]: Some modules break SIGUSR1 and SIGHUP
      ID: 14870 User updated by: msopacua at idg dot nl Reported By: msopacua at idg dot nl -Status: No Feedback +Status:...
    5. #14870 [Ana->Fbk]: Some modules break SIGUSR1 and SIGHUP
      ID: 14870 Updated by: sniper@php.net Reported By: msopacua at idg dot nl -Status: Analyzed +Status: ...
  3. #2

    Default Re: Dealing with SIGHUP

    [email]lvirden@yahoo.com[/email] wrote:
    >
    > I recently read a mailing list 'posting' that claimed that if
    > one typed
    >
    > (program arguments) </dev/null >> stdout 2>>stderr &
    >
    > that the resulting program would not die from a SIGHUP when the user
    > initiating the program logged off.
    The example given looks a little strange. Not sure why they want
    to read from /dev/null unless the program expects input - in which
    case backgrounding it isn't a very good idea. The output redirection
    looks silly too. ">>" means append. Are they appending to existing
    files?
    > Is that the general case in some/most/all shells?
    It depends on the shell.
    > I thought that to prevent SIGHUPs from killing your shell,
    Do you mean "prevent SIGHUPs from killing your process" here?
    > you either had to invoke the command using nohup, write SIGHUP handling code
    > yourself (assuming the shell allows it), or add code to the application to do
    > the SIGHUP handling
    Using nohup is the standard method but its not needed with all
    shells/programs. Handling a SIGHUP signal in the program itself
    is a good idea but you also really need to be careful about
    handling input and output. For some programs that expect no input
    and write to a log file or have their output redirected its not
    a problem.

    -am © 2003
    Anthony Mandic Guest

  4. #3

    Default Re: Dealing with SIGHUP

    In article <RzXMa.7$Qd3.92@paloalto-snr1.gtei.net>,
    Barry Margolin <barry.margolin@level3.com> writes:
    > In article <XHKMa.1894$GF2.1498733@twister.nyc.rr.com>,
    > <Cypherpunk@nyc.rr.com> wrote:
    >>Anthony Mandic <gf@hotmail.com> wrote:
    >>> [email]lvirden@yahoo.com[/email] wrote:
    >>> >
    >>> > I recently read a mailing list 'posting' that claimed that if
    >>> > one typed
    >>> >
    >>> > (program arguments) </dev/null >> stdout 2>>stderr &
    >>> >
    >>> > that the resulting program would not die from a SIGHUP when the user
    >>> > initiating the program logged off.
    >>>
    >>> The example given looks a little strange. Not sure why they want
    >>> to read from /dev/null...
    >>
    >>I've experience an 'rsh' sucking so hard on stdin that
    >>it advanced the place in the shell script that it was
    >>in where further commands were read from. (A number of
    >>commands after the 'rsh' in the shell script were skipped.)
    >
    > That doesn't seem likely. When a shell is running a script, the script is
    > not the standard input. The only way I can see that happening is if you
    > did:
    >
    > sh < scriptname
    >
    > instead of
    >
    > sh scriptname
    >
    > or
    >
    > scriptname
    >
    > Perhaps what you're thinking of is cases like:
    >
    > while read line;
    > do
    > rsh ...
    > done < filename
    >
    > This will only call rsh once, for the first line in filename, because rsh
    > will suck the rest of the file in.

    The solution to that would seem to be

    while read line;
    do
    echo "$line"|rsh ...
    done < filename

    although ksh print -r - "$line"
    would seem to be better than echo, 'cause it doesn't do escape sequences.

    --
    mailto:rlhamil@mindwarp.smart.net [url]http://www.smart.net/~rlhamil[/url]
    Richard L. Hamilton Guest

  5. #4

    Default Re: Dealing with SIGHUP

    In article <vg9cijl1vqhm4f@corp.supernews.com>,
    Richard L. Hamilton <Richard.L.Hamilton@mindwarp.smart.net> wrote:
    >In article <RzXMa.7$Qd3.92@paloalto-snr1.gtei.net>,
    > Barry Margolin <barry.margolin@level3.com> writes:
    >> Perhaps what you're thinking of is cases like:
    >>
    >> while read line;
    >> do
    >> rsh ...
    >> done < filename
    >>
    >> This will only call rsh once, for the first line in filename, because rsh
    >> will suck the rest of the file in.
    >
    >
    >The solution to that would seem to be
    >
    >while read line;
    >do
    > echo "$line"|rsh ...
    >done < filename
    >
    >although ksh print -r - "$line"
    >would seem to be better than echo, 'cause it doesn't do escape sequences.
    The usual solution is:

    while read line;
    do
    rsh -n ...
    done < filename

    or

    while read line;
    do
    rsh ... </dev/null
    done < filename

    Your version will work, but a reader of the code might assume that the
    command being rsh'ed actually uses the string that you're echoing to it, so
    it's a confusing way to write it.

    --
    Barry Margolin, [email]barry.margolin@level3.com[/email]
    Level(3), Woburn, MA
    *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
    Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
    Barry Margolin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139