[comp.unix.programmer] Exiting a program logs me out!

jmaynard@thesis1.hsch.utexas.edu (Jay Maynard) (11/26/90)

I'm trying to get the dte editor, which was recently posted to
comp.binaries.ibm.pc, to work on my System V. The author, Douglas Thomson,
included complete source, as well as an I/O module for HP-UX. Unfortunately,
it used the TIOCGETA and TIOCSETA functions and the sgttyb structure, which
aren't supported under vanilla System V. I figured out how to convert them to
termio calls, and got everything to compile.

When I run the program, though, it runs fine until I exit. It then gives me a
shell prompt - and then logs me off.

I'm sure this is something dumb that I'm doing, but I can't for the life of me
figure out what. Anyone out there run into this kind of problem before? If
you have, please drop me a note; I'll summarize if there's interest.

Thanks!
-- 
Jay Maynard, EMT-P, K5ZC, PP-ASEL | Never ascribe to malice that which can
jmaynard@thesis1.hsch.utexas.edu  | adequately be explained by stupidity.
         "With design like this, who needs bugs?" - Boyd Roberts

tif@doorstop.austin.ibm.com (Paul Chamberlain) (11/26/90)

In article <4366@lib.tmc.edu> jmaynard@thesis1.hsch.utexas.edu (Jay Maynard) writes:
>When I run the program, though, it runs fine until I exit. It then gives me a
>shell prompt - and then logs me off.

This is what happens when a program exits and leaves your "stty" hosed.
If you turn off icanon and have vmin/vtim set in a particular way, the
shell's read will timeout with 0 chars read -- the standard indication
of EOF.

Paul Chamberlain | I do NOT represent IBM.     tif@doorstop, sc30661 at ausvm6
512/838-7008     | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif

root@tndsyd.oz (the main man) (11/28/90)

In article <4366@lib.tmc.edu>, jmaynard@thesis1.hsch.utexas.edu (Jay Maynard) writes:
> 
> I'm trying to get the dte editor, which was recently posted to
> comp.binaries.ibm.pc, to work on my System V. The author, Douglas Thomson,
> included complete source, as well as an I/O module for HP-UX. Unfortunately,
> it used the TIOCGETA and TIOCSETA functions and the sgttyb structure, which
> aren't supported under vanilla System V. I figured out how to convert them to
> termio calls, and got everything to compile.
> 
> When I run the program, though, it runs fine until I exit. It then gives me a
> shell prompt - and then logs me off.
> 

I don't know the editor you talk about but if it uses CURSES then the 
problem may be inherent in libcurses.a. 

In some versions of CURSES (specifically in early System V), if nodelay() is
set somewhere in your program and not reset before the program exits, an EOF
is sent to the parent process that spawned the program. If the parent process
is the login shell then the user is logged off the system.

The trick is to place a line of code:
	nodelay(stdscr,FALSE);
just before calling endwin() in the exiting stages of your program.

Of course all this assumes the program uses CURSES.


.===========================================================================.
|   ACSnet: berny@tndsyd.oz       UUCP: uunet!munnari.oz!tndsyd.oz.au!berny |
| INTERNET: berny@tndsyd.oz.au  DOMAIN: goodheart_berny@tandem.com          |
|   PSMAIL: smtpgate @comm(berny@tndsyd.oz@munnari.oz.au)                   |
|  FIDONET: berny@f614.n713.z3.fidonet.org@tndsyd.oz.au  (3:713/614.0)      |
`==========================================================================='
TANDEM Computers Incorporated 76 Berry St, North Sydney, NSW, 2060, Australia