public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Start background process under bash
@ 2000-01-20 12:17 Joe Burpee
       [not found] ` <38877D2A.832984B7@veritas.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Burpee @ 2000-01-20 12:17 UTC (permalink / raw)
  To: cygwin

I have a bash script in which I start another script in the background
with the usual
	bgJob &
Works fine under Linux.  Under Cygwin b20.1 with Win95/98 I get an
annoying "illegal operation" popup every time, but the thing runs in the
background ok anyway, and the calling script continues in parallel.

As a workaround for the illegal op, I switched to using the following in
my bash script
	command.com /c start bash "bgJob"
It seems to me this just tells the DOS shell to do essentially the same
thing, and everything works ok, no popup.  Any number of processes seem
to run just fine in parallel.

Then I switched to NT4 (where the start command has slightly different
switches from Win9x).  Neither of the above works.  No popup, but the
calling script always *waits* for the background process, which doesn't
make a helluva lot of sense.

I assume the start command syntax is off-topic in this list, but I would
be interested if anyone knows what's wrong with "bgJob &".  Or if anyone
has another workaround for bash/Cygwin under NT, I would be very pleased
to hear about it.

Joe

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Start background process under bash
       [not found]   ` <388DF333.17F993A3@burkby.com>
@ 2000-01-25 12:09     ` Bob McGowan
  2000-01-25 15:55       ` Joe Burpee
  0 siblings, 1 reply; 3+ messages in thread
From: Bob McGowan @ 2000-01-25 12:09 UTC (permalink / raw)
  To: Joe Burpee; +Cc: Cygwin

Joe,

First, I'm adding the cygwin list back in the CC field.  This is
"normal" for discussion, so others can add or modify (and correct ;-)
suggestions, etc.

You mention using the DOS box "start /b" to get a process running in the
bash background.  Since the start command is part of the CMD.EXE and not
of bash, I'm not sure I understand what you are doing.  For a background
process in bash, you would run:

	bash-02$ command args... &
	bash-02$

which has always worked for me.  The ampersand tells bash to start the
command but not wait for it to exit.

Using start in a cmd prompt sort of emulates UNIX background processes,
but I believe the process structure of windows results in a brand new,
unrelated to the original, set.  (I am not an expert on this, though. 
Perhaps others could provide a more precise explanation.)  Suffice it to
say, I can do the following:

	bash-02$ cmd /c "start bash"

and get a brand new window with a bash command prompt, where the new
bash process (in cygwin/unix terms) is its own parent.  Normally, a
background process will have a parent PID equal to the process that
started it.  If I add the /b option to the start command in the above
example,  I get 2 bash shells competing for the single input focus.  A
ps -f in a separate shell still shows that the bash running via the
start command is its own parent (so not a "true" background process) and
is not manageable using the bash 'jobs' command or the '%#' background
jobs referencing features.

I hope this helps point you in a useful direction.

Bob

Joe Burpee wrote:
> 
> Bob McGowan wrote:
> > You didn't mention whether you are using the beta or CD version.
> 
> I'm using B20.1 (beta); sounds like I should get the CD.
> 
> > I am using the Cygwin CD 1.0, no updates, on both NT4 and NT2K and can
> > run processes in the background inside a scripts using the & without any
> > error popups (in fact, I am running a script now - actually puts a
> > function in the background, which is done by running multiple copies of
> > bash).  You may want to try "standard" method again (in case you haven't
> > yet).
> 
> I think my client's NT4 setup must be snafu.  Using the DOS box command
> "start /b" I can get one process running in the bash background, but
> only one.  And other processes, like readline, seem to be dead while the
> background job is running.  I guess there's a process priority problem
> somewhere.
> 
> Thanks for the info.  Some reason for optimism.
> 
> Joe

-- 
Bob McGowan
Staff Software Quality Engineer
VERITAS Software
rmcgowan@veritas.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Start background process under bash
  2000-01-25 12:09     ` Bob McGowan
@ 2000-01-25 15:55       ` Joe Burpee
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Burpee @ 2000-01-25 15:55 UTC (permalink / raw)
  To: cygwin

Bob McGowan wrote:
> First, I'm adding the cygwin list back in the CC field.  This is
> "normal" for discussion, so others can add or modify (and correct ;-)
> suggestions, etc.

Hey, no problem Bob.  You mailed me off-list, so I assumed you didn't
want to go public with your comments.

> You mention using the DOS box "start /b" to get a process running in the
> bash background.  Since the start command is part of the CMD.EXE and not
> of bash, I'm not sure I understand what you are doing.  For a background
> process in bash, you would run:
> 
>         bash-02$ command args... &
>         bash-02$
> 
> which has always worked for me.  The ampersand tells bash to start the
> command but not wait for it to exit.

Right, and as I mentioned I'm getting an annoying "illegal op" pop-up in
Win9x, although the child process does run ok.  And in NT4 the parent
just sits there and waits, as though the "&" wasn't there.

> Using start in a cmd prompt sort of emulates UNIX background processes,
> but I believe the process structure of windows results in a brand new,
> unrelated to the original, set.  (I am not an expert on this, though.
> Perhaps others could provide a more precise explanation.)  Suffice it to
> say, I can do the following:
> 
>         bash-02$ cmd /c "start bash"
> 
> and get a brand new window with a bash command prompt, where the new
> bash process (in cygwin/unix terms) is its own parent.  Normally, a
> background process will have a parent PID equal to the process that
> started it.

This is ok with me as I don't want the calling process to manage the
child(ren).  (Just spawn, and say goodbye.)  And I can live with the
separate window, for the sake of getting rid of the stupid pop-up in
Win9x.

> If I add the /b option to the start command in the above
> example,  I get 2 bash shells competing for the single input focus.

Yup.  This seems consistent with the sparse documentation I've found on
cmd.exe.

> A ps -f in a separate shell still shows that the bash running via the
> start command is its own parent (so not a "true" background process) and
> is not manageable using the bash 'jobs' command or the '%#' background
> jobs referencing features.

Thanks for elaborating this stuff.  As I mentioned before, I can live
with the "command.com /c start ..." fix in Win9x, but even that doesn't
work with cmd.exe on my client's NT4 installation.  There the "/b"
switch does allow me to launch a separate process, but even then I'm
running into conflicts; e.g. I can use the (grand)parent shell, but
readline (filename completion in particular) doesn't work.

Anyway, as I said these cmd.exe/command.com workarounds may be somewhat
off-topic, but I would be really interested if anyone can suggest why
the bash "&" does not seem to be working in all the Win environments
I've tried.  No doubt I'm doing something wrong, but I have no idea
what.  I'm used to Linux (where the script  works every time, of
course).

Joe

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-01-25 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-20 12:17 Start background process under bash Joe Burpee
     [not found] ` <38877D2A.832984B7@veritas.com>
     [not found]   ` <388DF333.17F993A3@burkby.com>
2000-01-25 12:09     ` Bob McGowan
2000-01-25 15:55       ` Joe Burpee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).