Logoff after exiting program - the answer

Jay Maynard jmaynard at thesis1.hsch.utexas.edu
Mon Nov 26 23:40:29 AEST 1990


Well, it turns out that I wasn't doing enough. Not only do you have to save
and restore the termio values (via saving a copy of the original termio
structure and using it as the argument of a TCSETA ioctl()), but, at least
on my NCR Tower XP, you also have to save the file status flags via
fcntl(0,F_GETFL,0) and restore them by fcntl(0,F_SETFL,saved_value).

I've gotten two responses:
Raymond Chen (raymond at math.berkeley.edu) suggested that I was tickling a
known csh bug; the description bears repeating:
>First, a few guesses:
>[1] You're running csh.
>[2] It doesn't log you out immediately, but rather as soon as you
>type anything, it acts as if you typed Ctrl-D and logs you out.
>If [1] and [2] are true, then my vague memory tells me that this is
>a known csh bug that occurs when somebody leaves the tty in a funky state.
>(Has to do with the wrong parity or something.)
This was a nice guess...but I'm running sh.

Joe English (jeenglis at alcor.usc.edu) came close...  
>You didn't specify which termio calls you used, but I've got a guess
>as to what might be wrong (I had the same problem once.)
>If you set the terminal to use non-blocking, asynchronous I/O, and
>don't reset it before exiting, when the shell tries to read a command
>line it gets zero bytes back, which it interprets as an end-of-file.
>(The fix is to restore the terminal to cooked, blocking mode before
>exiting.)  If you're using csh, you can 'set ignoreeof' to check if
>this really is the problem.
It turns out that he's right; the problem is that there's more state than
just the termio structure. (Argh!)

Thanks for your help...once again, the net comes through!
-- 
Jay Maynard, EMT-P, K5ZC, PP-ASEL | Never ascribe to malice that which can
jmaynard at thesis1.hsch.utexas.edu  | adequately be explained by stupidity.
         "With design like this, who needs bugs?" - Boyd Roberts



More information about the Comp.unix.programmer mailing list