Bourne shell (sh) behaviour

Bourne shell (sh) behaviour

Post by Gennady Kuznets » Tue, 05 Jun 2001 15:16:17



Hi!

We use Digital UNIX 4.0D....

When I launch some program BY NOHUP (#nohup <program> &) in background
and then exit parent Bourne shell (sh), the program terminates. nohup
doesn't work! Why this can be?

Thanks

 
 
 

Bourne shell (sh) behaviour

Post by Juergen P. Mei » Tue, 05 Jun 2001 18:49:51



>Hi!

>We use Digital UNIX 4.0D....

>When I launch some program BY NOHUP (#nohup <program> &) in background
>and then exit parent Bourne shell (sh), the program terminates. nohup
>doesn't work! Why this can be?

probably because the sh sends a SIGTERM to all it's childs when exiting.
(nohup just prevents SIGHUP from terminating you program and redirects
stderr, stdin and stdout)

Do this in ksh, it has a working job control.

Juergen

--


 
 
 

Bourne shell (sh) behaviour

Post by Gennady Kuznets » Wed, 06 Jun 2001 14:42:40




> >Hi!

> >We use Digital UNIX 4.0D....

> >When I launch some program BY NOHUP (#nohup <program> &) in background
> >and then exit parent Bourne shell (sh), the program terminates. nohup
> >doesn't work! Why this can be?

> probably because the sh sends a SIGTERM to all it's childs when exiting.
> (nohup just prevents SIGHUP from terminating you program and redirects
> stderr, stdin and stdout)

> Do this in ksh, it has a working job control.

> Juergen

Thanks for your suggestion. But i have one more question about Bourne
shell:
where can i find detailed description of sh behaviour (in terms of
"process group", "session leader", "controlling terminal", "signal",
etc.)?

Gennady.

 
 
 

Bourne shell (sh) behaviour

Post by Rinaldi J. Montes » Wed, 06 Jun 2001 09:57:16



> Hi!

> We use Digital UNIX 4.0D....

> When I launch some program BY NOHUP (#nohup <program> &) in background
> and then exit parent Bourne shell (sh), the program terminates. nohup
> doesn't work! Why this can be?

> Thanks

Did you look at info nohup?  Appears to be only one thing for sure to
cause it not to run.  

Rinaldi
--
We all know Linux is great...it does infinite loops in 5 seconds.
--Linus Torvalds

 
 
 

Bourne shell (sh) behaviour

Post by Tige » Wed, 06 Jun 2001 20:43:04





> > >Hi!

> > >We use Digital UNIX 4.0D....

> > >When I launch some program BY NOHUP (#nohup <program> &) in background
> > >and then exit parent Bourne shell (sh), the program terminates. nohup
> > >doesn't work! Why this can be?

> > probably because the sh sends a SIGTERM to all it's childs when exiting.
> > (nohup just prevents SIGHUP from terminating you program and redirects
> > stderr, stdin and stdout)

> > Do this in ksh, it has a working job control.

> > Juergen

> Thanks for your suggestion. But i have one more question about Bourne
> shell:
> where can i find detailed description of sh behaviour (in terms of
> "process group", "session leader", "controlling terminal", "signal",
> etc.)?

> Gennady.

You raised both of these questions in  comp.unix.admin. and  somebody
posted the solution also i guess.

Regards,
Tiger.

 
 
 

Bourne shell (sh) behaviour

Post by Juergen P. Mei » Thu, 07 Jun 2001 17:27:31




>> Hi!

>> We use Digital UNIX 4.0D....

>> When I launch some program BY NOHUP (#nohup <program> &) in background
>> and then exit parent Bourne shell (sh), the program terminates. nohup
>> doesn't work! Why this can be?

>> Thanks

>Did you look at info nohup?  Appears to be only one thing for sure to
>cause it not to run.  

no, i looked at the manpage. I dislike GNU info docs, i prefere
the manpages for standards compliant software.
But thats just it. Otherwise i like most GNU tools more than
the Unix versions.

And i know the behaviour of the Bourne shell and it's nonexisting
Jobcontrol. Its nothing that nohup can fix.

Quote:>Rinaldi

juergen

--

 
 
 

Bourne shell (sh) behaviour

Post by Nick Col » Sun, 10 Jun 2001 01:55:20





> > Hi!

> > We use Digital UNIX 4.0D....

> > When I launch some program BY NOHUP (#nohup <program> &) in background
> > and then exit parent Bourne shell (sh), the program terminates. nohup
> > doesn't work! Why this can be?

why not use batch (i.e. at now)?

batch << done
<program>
done

 
 
 

1. Light Speed Bourne Shell! (was: Bourne shell tricks)

                              WARP SPEED TESTS!

For a light-speed bourne shell script, I just found out a really cool trick:
        if [ "$var" = "condition" ]; then list; fi
becomes:
        case "$var" in "condition") list;; esac

Take this example, two scripts:
        if.sh:
                for x in `jot 1000`; do
                        if [ $x = 1000 ]; then echo "Done"; fi
                        done
        case.sh:
                for x in `jot 1000`; do
                        case $x in 1000) echo "Done";; esac
                        done

("jot" is just some weird util we have here that prints out numbers)
Now take a look at the runtimes (on a DECstation/240 with not much load):
#0 /tmp/JAMtmp> time sh case.sh
                real    0m0.53s
                user    0m0.11s
                sys     0m0.05s
#0 /tmp/JAMtmp> time sh if.sh  
 ^--return code of last cmd in prompt ;-)
                real    0m32.43s
                user    0m1.95s
                sys     0m16.80s
So, case instead of test is:
real:   61 times faster
user:   18 times faster
sys :   31 times faster

...So use case instead of if whenever you can! (just remember the case will
interpret your condition as a pattern!)

--

  n  r    
  a JAMax  "Thou shalt not kill...  Thou shalt not steal...
  h o   w   Thou shalt not covet thy neighbour's...ass nor any
  tan lle   thing that is thy neighbour's."  --Bible

2. Year 2000 Millenium Bug going to be a problem? Not any more!

3. Bourne Shell (/bin/sh) counting?

4. XDM-How to start other WM instead of FVWM95 in RedHat4?

5. Should the Bourne shell (/bin/sh) expand tilde (~) for home directories?

6. networking questions, one X question

7. How to set $PWD Prompt for Bourne(sh) Shell in SCO UNIX?

8. 4.0 upgrade - ata driver switch problem

9. Setting $PWD Prompt for Bourne (sh) Shell in SCO UNIX??

10. Scope & Privacy of variables in Bourne Shell (sh)

11. Bourne Shell (/bin/sh) & clobber

12. sh: how to write recursive functions in Bourne shell?

13. Bourne Shell (/bin/sh) counting?