Technical article 118583

Modem dial-in session remains active after line is physically disconnected.

OpenServer 5.0.6

Written · Last revised

Problem

I have configured a modem for dial-in to an OpenServer 5.0.6 system. I wish to trap the "hangup" signal 1 (SIGHUP), in case, for instance, I receive a hangup signal abnormally, and want to log or save some information about the session before it terminates.

Thus, I place the following line in my .profile:

trap 'nohup sh foobar.sh >> logfile ; exit' 1

which will trap SIGHUP and run the "foobar.sh" script to perform the information gathering tasks before the session exits.

However, when the session hangs up abnormally, for instance, when the phone line is detached from the modem while a user is logged in, the login shell and its children do not terminate, but remain running.

This problem applies to both /bin/sh and /bin/ksh logins, and may also be reproduced with:

trap 'exit' 1
instead of the above.  It occurs regardless if Release
Supplement RS506A is applied.

In previous OpenServer releases, the login shell and all of its children generally terminate under similar conditions.

The problem does not occur, however, when the login shell is idly
waiting to read a command from the tty.  It only happens when the
shell is waiting for a child or otherwise busy executing commands.

Solution

This problem has been reported to SCO/SCO Engineering.

Currently, there are two workarounds:

1) Substitute the OpenServer 5.0.5 /bin/login binary for the 5.0.6 version of /bin/login.

In 5.0.5, /bin/login forks and execs the login shell.  Hence a
"parent" /bin/login process sticks around for the duration of
the login session.  If you choose workaround, see TA 104851,
"I get the message "LOGIN: ERROR- Failed to initialize policy
manager", section 5 of the SOLUTION, for a discussion of socket
resource issues that could occur on a system with a very large
number of simultaneous users.
2) Use the opensource shell "bash" in place of sh or ksh for modem
   dialin logins.  You can obtain bash from our Skunkware software
   for OpenServer 5.  To download Skunkware software, go to:
http://www.sco.com/download
Choose Skunkware from the product selection list.  Browse the
OpenServer package list, and find bash.
Because bash is a job control shell, it places its children in
another process group, and when an accidental modem hangup
occurs, these child processes will generally remain as an
"orhpaned" process group.  This is generally not a problem for
subsequent logins, as the orphans will be terminated upon any
attempted I/O on the modem tty.
NOTES:  I am seeing a similar problem on different SCO Unix OS's regardless of
        release over 'telnet' or 'rlogin' connections.

How does the user they run their application, is it direct from a user's .profile?

If so, is it trapped against someone just terminating their emulator or turning off the PC without logging out cleanly?

The shell will automatically send a SIGHUP ( kill -1 ) to each child
process when the shell is dieing.  Either the child processes are
trapping signal 1 or perhaps there is a trap in /etc/profile
or .profile.

The best way to lock a user into a script is by making the first line of .profile "trap" and making the last line "exec", eg:

We're looking for something like:
trap "" 1 2 3 9 15
...
exec /usr/bin/main_menu

From the Xinuos technical article database, record 118583. Reproduced with permission. The original is at www.sco.com/ta/118583, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.