detach a process
David A. Bandel
david
Mon May 17 11:46:18 PDT 2004
On Sat, 5 Apr 2003 21:41:44 -0800
Shawn Tayler <stayler at xmtservices.net> wrote:
>
>
> Hi Guys,
>
> Is there an easy way at the command line to start a detached process,
> ie. in OS/2 you could type "detach 'any command you wanted to run'"
> The command would run and the detached session would terminate with
> the command. An example would be "detach copy
> very.large.group.of.files h:"
>
> I am sure that detach is not the term used under Linux, but it was a
> real handy tool. There must be such a thing...
Yes, there is something similar.
In a BASH shell, you can take a process running in the foreground and
put it into the background via the following:
<Ctrl>+Z (this pauses execution and give you a command line)
bg (this tell the process to go into the background)
you can do the same thing as above when you start the command by putting
'&' at the end of the command line (./myprogram &)
any command you shoved into the background, you can see using the
command:
jobs
you can bring it to the foreground using:
fg
if you have a number of jobs, you can reference to them by number. You
can foreground or kill them (using the fg or kill commands).
Problems:
some commands will exit when you background them and exit the shell.
These are usually programs that expect or need a controlling terminal.
Also, your program may hang if it's running in the background and
requires input because you now cannot provide it input (nor can it
provide you output).
If you must start a program you don't want to exit when you logout, try
running it with `nohup` (nohup ./myprogram &). Don't forget the '&' at
the end.
The above only works with shells so programmed. I know it works with
BASH, others may or may not work as above.
HTH,
David A. Bandel
--
Focus on the dream, not the competition.
Nemesis Racing Team motto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.linux-sxs.org/pipermail/linux-users/attachments/20030406/f8728717/attachment.pgp
More information about the Linux-users
mailing list