Operating System - HP-UX
1833785 Members
2541 Online
110063 Solutions
New Discussion

What is the signal for click x button?

 
Ngoh Chean Siung
Super Advisor

What is the signal for click x button?

Hi,

I am using tera term and telnet emulation to connect to the HP server. May I know what is the signal for clicking x button which is located on top?

Because we need to trap this termination signal in order to prevent user login session still alive even user already exit the emulation.

regards.

5 REPLIES 5
Bill Hassell
Honored Contributor

Re: What is the signal for click x button?

The X button is the window termination button which has nothing to do with HP-UX. The termination of the window will generate a SIGHUP (hangup signal) which your application can trap, but you cannot prevent the user from closing the window (or turning off the computer).

Now if you are saying that the user session is still running after the telnet window is closed, that means that the SIHUP trap is not set. To verify this, login as a user, then at a shell prompt, type the command:

trap

It will show you the signals that are trapped. A properly setup HP-UX login will have the hangup signal enabled and if it occurs (because the telnet session is terminated abnormally), your application and the login session will be signaled to terminate.

If you see that trap is not set, you can re-enable traps by typing:

trap 1 2 3

which restores normal behavior, then run your applcation and close the window. Your login session should terminate normally.


Bill Hassell, sysadmin
Ngoh Chean Siung
Super Advisor

Re: What is the signal for click x button?

Hi Bill,

Allows me to explain to you in more details.

Basically after my users login to server, they will access a main menu (.mnu) which used to access informix application. All the users .profile content is only has 1 line which is 'exit'. So, they will follow the parameters set in /etc/profile.

Before server upgrade from HP10 to HP11, everything is working fine. They are following the profile (attached as profile_org). In this file, I hv highlight the lines as blue colour. These lines was disabled after server upgrade. (attached as profile_now). You may use wordpad to open these files.

1) By using profile_org
The problem is after user access the option in .mnu, if the user terminate it by clicking x button, the user session still alive (can track by using w command). The process that the user running is the statements that after 'if [ -s $HOME/.mnu ]'. When I use w command to check, what I can see is the user session is still there. The JCPU and PCPU will keep on increasing. Below is the output if using w command:
# w | grep ncs
root pts/ty 10:51am grep ncs
ncs pts/tE 10:54am 2 2 -sh

# ps -t pts/tE
PID TTY TIME COMMAND
26474 pts/tE 0:03 sh
26473 pts/tE 0:00 telnetd

2) By using profile_now,
Everything is ok IF without any trap tracking and disable the while loop for .mnu. The user session will disappear even user click x button.

For my requirement, I want to disable trap signal 1 2 3 and enable it at the end of the profile. Is there any script that we can put inside the profile to kill sh id which is after telnetd IF user click x button?

regards.
Ngoh Chean Siung
Super Advisor

Re: What is the signal for click x button?

Hi,

Attached is the files for profile and .mnu.
Muthukumar_5
Honored Contributor

Re: What is the signal for click x button?

USe like,

trap 'function to be executed on getting signal' 1 2 3

See trap man page.

--
Muthu
Easy to suggest when don't know about the problem!
Bill Hassell
Honored Contributor

Re: What is the signal for click x button?

Yes, the current login prfile has traps 1 2 and 3 disabled. Don't worry, it is a common mistake (I made it myself several years ago). At the top of your profile, you'll see:

trap : 1 2 3

which is the same as: trap "" 1 2 3 and means: if signals for SIGHUP, SIGINT or SIGQUIT are seen, do nothing (ignore). Then down at the bottom of the profile, you'll see this:

# Leave defaults in user environment.

# trap 1 2 3

Oops (I did the same thing a long time ago), someone saw what appears to be the same statement at the beginning of your script, so it was commented out. Just remove the comment and your profile will work as you desire. The traps are disabled at the beginning, then re-enabled before the menu program starts.


Bill Hassell, sysadmin