niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » Solaris
ssh not exiting because of spawned process
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Old Wolf
*nix forums Guru


Joined: 20 Feb 2005
Posts: 679

PostPosted: Fri Jul 21, 2006 12:54 am    Post subject: ssh not exiting because of spawned process Reply with 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.

"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

PostPosted: Fri Jul 21, 2006 6:52 am    Post subject: Re: ssh not exiting because of spawned process Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Sun Nov 23, 2008 1:20 pm | All times are GMT
navigation Forum index » *nix » Solaris
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Help! Shared memory is getting deleted after process is k... Anuradha apps 3 Thu Jul 20, 2006 8:42 am
No new posts High paging usage on database process mychrislo@gmail.com AIX 0 Wed Jul 19, 2006 9:59 am
No new posts process taking long time to dump core techimadhu C 4 Wed Jul 19, 2006 6:52 am
No new posts shared objects cannot be overwritten even though the proc... prashantarane@gmail.com AIX 3 Wed Jul 19, 2006 6:33 am
No new posts rename multiple remote files in sftp process. s4shoaib@gmail.com shell 1 Mon Jul 17, 2006 6:43 pm

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
[ Time: 0.2942s ][ Queries: 16 (0.2129s) ][ GZIP on - Debug on ]