[aklug] Re: terminal types and curses programming

From: Arthur Corliss <acorliss@nevaeh-linux.org>
Date: Wed Jan 28 2009 - 08:18:45 AKST

On Mon, 26 Jan 2009, Christopher Howard wrote:

> I'm going to sound like a real noob here, but can you explain a bit more
> about the 'trap' and 'exit' part? Is this something I'm supposed to add to
> some init script or something? (I'll read the man pages if you'll point me to
> the right ones.)

Both are internal bash calls, so they're documented in the man page for it.

In a nutshell, rc files are sourced, not executed in an external process.
So, if you 'exit' there, the shell will exit, and the remote login
terminated. So, if you wanted to launch your program from the rc scripts
you'd do:

   minmenu
   exit $?

or similar. That would guarantee that regardless of how minmenu terminated
the login session would end as well.

You'd use trap to set signal handlers to prevent someone from trying to
perform a CTRL+C to interrupt sourcing of the rc scripts and dropping them
into a shell before your program was executed. Theoretically, even when
using exit after minmenu in the rc script there's a chance that you could
have SIGINT follow SIGCHILD so closely that the exit command never gets
executed. This is just a security precaution.

> Another question: Does having my program as the user's default login shell
> have any other drawbacks (that is, since the program isn't really a shell).
> It doesn't matter to other programs what the default shell is, or does it?

Some programs check to see if a shell if valid (i.e., listed in
/etc/shells), but for 90% of the software out there it should cause you any
problems.

         --Arthur Corliss
           Live Free or Die
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Jan 28 08:18:56 2009

This archive was generated by hypermail 2.1.8 : Wed Jan 28 2009 - 08:18:56 AKST