Re: interpretation issue with "nohup command &"
am 01.04.2008 11:16:37 von itsolutionBTW, nohup is really necessary?
On my tcsh, I just typed following and then closed my ssh client
shell:
make mytartarget |& tee buildlog.txt &
Both make process and tee process are still continuing!
SIGHUP is not delivered to those 2 back ground processes ?? Only to
the parent tcsh process ?
On Mar 25, 8:00 pm, Wayne
> itsolut...@gmail.com wrote:
> > Hi Guys,
>
> > On the shell[tcsh], when I type
> > nohup make mytartarget |& tee buildlog.txt &
>
> > Does 'nohup' take priority or the trailing '&' takes priority ?
>
> > In other words, how shell interprets it? In which way out of
> > followings
> > 1)
> > nohup makes [make mytartarget |& tee buildlog.txt &] immune to
> > hangup
>
> > 2)
> > lets [nohup make mytartarget |& tee buildlog.txt] run as
> > background
>
> > According to my test, shell interprets in 1) approach.
>
> > Any explanation will be appreciated!
>
> This is a complex question. tcsh has a built-in version of
> nohup, which is slightly different than the Gnu /usr/bin/nohup,
> which is (currently) different than POSIX/SUS nohup.
>
> Nohup fires up a shell that ignores SIGHUP,
> which then interprets the rest of the command line.
> The nohup command is "make mytartarget".
>
> The csh "|&" starts the second command simultaneously, redirecting
> both stdout and stderr into the stdin of the command, in your
> case "tee buildslog.txt".
>
> The final "&" means to not wait for that final command (the
> nohup is already running in the background) before issuing
> a new prompt.
>
> Note you can see this easily if you log out and log in, and
> run ps -ef (or ps alx) to show all running processes; you
> should see the nohup make process running but not the
> tee process.
>
> There are a couple of points to note. The tee is not needed,
> you can just run "nohup make mytartarget &" and the output
> goes to "nohup.out". You can view that file with
> "tail -f nohup.out".
>
> Secondly, to run a complex pipeline you can use nohup to
> start a shell which will run your pipeline with each
> command ignoring the hangup signal. Something like this:
>
> nohup tcsh -c 'make mytartarget |& tee buildlog.txt'
>
> (Personally I find it easier to create a shell script that
> does anything complex, and then run "nohup myscript &".)
>
> -Wayne