LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2009, 03:17 PM   #1
sleeper0110
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Rep: Reputation: 0
Replacement for shell becomes an orphan


I have written a replacement for shell standard shell. So when a user logs in they are presented with my custom shell app.

My problem is remote logins (i.e. a user that logs in via SSH). If they log in remotely and are using the custom shell, but the SSH process suddenly dies (for whatever reason) the custom shell app. doesn't end, it becomes an orphan (i.e. the init process becomes the parent).

Now, when I use a standard shell and the SSH process dies suddenly, the shell dies right away.

Can anybody explain this? I'd like the custom shell to die when it's parent process (usually SSH) dies. I'd prefer to do this without threads.

Thoughts?

Thanks.
 
Old 10-05-2009, 04:33 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Most likely it'll be in the difference between how the getty process spawns the login shell and how it spawns the login shell replacement. If it's not that then you might have coded something keeping it from dying properly. In both cases posting details should clear things up real quick.
 
Old 10-05-2009, 04:52 PM   #3
sleeper0110
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Original Poster
Rep: Reputation: 0
You were right about: "you might have coded something keeping it from dying properly."
When I was building this shell app. I didn't want people killing it by sending it term/int/etc signals so I wrote a signal handler to ignore a bunch of signals. I went through the signals I was ignoring one by one and found the one that was keeping it alive: HUP. I thought it was odd that HUP was the one keeping it alive (I figured maybe SIGSTOP or something).

I no longer ignore HUP and it seems to be dying when the SSH session dies.

Thanks.
 
Old 10-05-2009, 05:44 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 10-05-2009, 06:37 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
As an FYI, SIGHUP stands for SIGnal Hang UP. It was used in the days of dial-in modems, etc., to indicate that the other end had "hung up".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacement utilities written in pure shell gnashley Programming 9 08-17-2007 11:23 AM
multiple character replacement by shell script mauran Programming 14 07-13-2007 02:46 AM
is there a way to remove orphan packages? keratos Mandriva 5 06-20-2007 02:43 AM
Shell Script - String Replacement revof11 Programming 7 11-29-2005 06:38 AM
Orphan Processes LiquidPenguin Linux - Newbie 0 07-15-2003 10:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration