On Wed, Jun 30, 2010 at 9:12 AM, Clark J. Wang <dearv...@gmail.com> wrote:
> On Wed, Jun 30, 2010 at 1:40 PM, Jan Schampera <jan.schamp...@web.de> > wrote: > > > Clark J. Wang wrote: > > > > Running a cmd in background (by &) would not create subshell. Simple > >> testing: > >> > >> #!/bin/bash > >> > >> function foo() > >> { > >> echo $$ > >> } > >> > >> echo $$ > >> foo & > >> > >> ### END OF SCRIPT ### > >> > >> The 2 $$s output the same. > >> > > > > This doesn't mean that it doesn't create a subshell. It creates one, > since > > it can't replace your foreground process. > > > > This makes sense. > > It just shows that $$ does what it should do, it reports the relevant PID > of > > the parent ("main") shell you use. > > > Then what's the problem with my script in my original mail? Seems like Bash > does not handle the signal in a real-time way. > > the signal is delivered after the foreground process "sleep 3600" exits, try with: "sleep 3600 & wait $!" instead