|
|
|
|
|
|
| Author |
Message |
Old Wolf *nix forums Guru
Joined: 20 Feb 2005
Posts: 679
|
Posted: Fri Jul 21, 2006 12:54 am Post subject:
ssh not exiting because of spawned process
|
|
|
I'm using "ssh" that came with Solaris 10, to run a process on a
remote host (also Solaris 10), using RSA authentication:
ssh hostname "/path/to/foo"
"foo" is a small program that spawns a process (let's call it
foo_spawn) and then exits. What I would like to happen is that
as soon as "foo" exits, the ssh session ends, and foo_spawn
remains running on the remote system.
However, what is actually happening is that the ssh stays open,
and stderr messages from foo_spawn will appear on the ssh terminal.
The ssh will not exit until foo_spawn is killed.
"ps -ef" on foo_spawn shows it as owned by PID 1 and not connected
to any terminal, although the evidence above would seem to suggest
that it is still connected to the ssh terminal somehow.
"foo" does the spawning by calling fork(), and then the forked process
calls setsid() and then parent process exits.
What's going on here? |
|
| Back to top |
|
 |
Andrew Gabriel *nix forums Guru
Joined: 19 Feb 2005
Posts: 454
|
Posted: Fri Jul 21, 2006 6:52 am Post subject:
Re: ssh not exiting because of spawned process
|
|
|
In article <1153443262.713084.11590@s13g2000cwa.googlegroups.com>,
"Old Wolf" <oldwolf@inspire.net.nz> writes:
| Quote: | I'm using "ssh" that came with Solaris 10, to run a process on a
remote host (also Solaris 10), using RSA authentication:
ssh hostname "/path/to/foo"
"foo" is a small program that spawns a process (let's call it
foo_spawn) and then exits. What I would like to happen is that
as soon as "foo" exits, the ssh session ends, and foo_spawn
remains running on the remote system.
However, what is actually happening is that the ssh stays open,
and stderr messages from foo_spawn will appear on the ssh terminal.
The ssh will not exit until foo_spawn is killed.
What's going on here?
|
You have forgotten to make sure foo_spawn has no filedescriptors open
to the tty. Either close stdin/stdout/stderr when calling foo_spawn,
or better still, get foo_spawn to do so. Look up how to deamonize a
process -- the setsid() is only part of it.
--
Andrew Gabriel |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sun Nov 23, 2008 1:20 pm | All times are GMT
|
|
Property in Spain | Mobile Phone deals | Loans Bad Credit | Car Finance | Mortgages
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|