home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!munnari.oz.au!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!news.lth.se!pollux.lu.se!balder.tf1.lu.se!gs
- From: gs@balder.tf1.lu.se (Goran Svensson)
- Subject: Re: * IDLE OUT ON RS/6000 *
- Message-ID: <1993Jan27.150954.10492@pollux.lu.se>
- Summary: PSOIX and SIGHUP and so on
- Keywords: PSOXI, SIGHUP, Idonotunderstand
- Sender: goran@btj.se
- Nntp-Posting-Host: balder.tf1.lu.se
- Organization: none
- References: <C14Dzu.owr@austin.ibm.com> <117@DSM530.UUCP> <C18nK1.1MDK@austin.ibm.com>
- Date: Wed, 27 Jan 1993 15:09:54 GMT
- Lines: 226
-
- Sorry folks, I really would love to take this one of stage, but since
- I am not allowed to mail to IBM I have to reply here. This is directed
- to Rich Coe and John Haugh @austin.ibm.com who were kind enought to answer
- my previous question (or anyone else who may know)
-
-
- ----- Transcript of session follows -----
- 550 Mailing across IBM boundary not authorized
-
- ---
-
-
- Thanks to both of you for taking the time to answer me, this is a problem that
- has been bugging me for a while.
-
- I am not totaly familiar with the concept of foreground and background
- processes, but here is what I do:
-
- I have a telnet based terminal server, from which I log in to my AIX.
- While there I start a program (any program), and then my terminal is
- switched of (that is, the telnet session dies. The same behaviour has been
- observed between 2 AIX machines when I ^T and quits telnet). The ksh dies
- but the program is not notified. The read terminates with 0, so that part
- works fine, but as Rich says, there are many programs out there who does
- not expect this behaviour. No signal is processed, and the program is allowed
- to proceed. A 'simple' program in included below, just to show what I am doing.
-
- John (or Rich), I expect the program to be a part of the foreground process
- group and should receive a SIGHUP. I had a case with IBM during the autumn
- and it was terminated when Andre Mbus at IBM gave me this answer:
-
- ...
- This is what happening: on the telnet client side when the terminal is
- turned off the shell send a SIGHUP to telnet as a result telnet get
- killed during that process telnet close the connection and send a FIN
- to telnetd which in turn close the pty and any process which
- try to read or write
- to that tty get and EOF. So there is no SIGHUP send to telnetd
- and telnetd does not send a SIGHUP signal to foreground
- processes. The
- application should not be looking for SIGHUP but to check if the tty is
- still opened.
- ... ( I copied the answer letter by letter to keep the original phrasing and
- spelling)
-
- Is it really so? If I do not misread your answers, I tend to say no.
- John, you state that if the program was started by the session leader,
- I should receive a SIGHUP. Well, I don't. And I did have a case with IBM.
-
- I do not know what is right and what is wrong, but if you are right, then
- Andre is wrong (or, most plausible, I am totally wrong).
-
- Regards,
- Goran Svensson
- BTJ System AB
- Sweden
- goran@btj.se
- --- Program follows ---
-
- #include <signal.h>
- #include <stdio.h>
- #include <setjmp.h>
- #include <errno.h>
-
- static jmp_buf jmp_intr;
-
- /*
- --------------------------------------------------------------------------------
- */
- #include <sys/time.h>
- #include <sys/types.h>
-
- char *adate()
- {
- int status, len;
- char *sccs_id="@(#) adate() 1.0 930120 Return pointer to time of day";
-
- struct timestruc_t current_time;
- char *today;
- time_t ct;
-
- status = gettimer( TIMEOFDAY, ¤t_time );
-
- ct = current_time.tv_sec;
-
- today = ctime( &ct );
-
- /* Remove trailing \n */
- len = strlen(today);
- today[len-1] = '\0';
-
- return( today );
-
- }
- /*
- --------------------------------------------------------------------------------
- */
-
- static void report_alarm( char *message )
- {
- char *date;
- FILE *logfile;
-
- date = adate();
-
- printf( "%s\n", message );
- printf( "Interrupted at %s\n ", date );
-
- logfile = fopen("/tmp/traps.log", "a");
- if ( logfile != (FILE *)0 ) {
- fprintf( logfile, "%s. Interrupted at %s\n", message, date );
- fclose(logfile);
- }
- else
- fprintf( stderr, "Could not open logfile /tmp/traps.log\n");
-
- exit(1);
- /*
- longjmp( jmp_intr, 1 );
- */
- }
-
- static void alarm_dfl() /* hangup, generated when terminal disconnects */
- {
- report_alarm( "alarm_dfl: A default signal 0 has been found" );
- }
-
- static void alarm_hup() /* hangup, generated when terminal disconnects */
- {
- report_alarm( "alarm_hup: Someone just hanged up" );
- }
-
- static void alarm_int() /* interrupt, generated from terminal special char */
- {
- report_alarm( "alarm_int: I was interrupted" );
- }
-
- static void alarm_quit() /* (*) quit, generated from terminal special char */
- {
- report_alarm( "alarm_quit: I has been told to quit" );
- }
-
- static void alarm_ill() /* (*) illegal instruction (not reset when caught)*/
- {
- report_alarm( "alarm_ill: I do not believe this, an illegal instruction" );
- }
-
- static void alarm_segv() /* (*) segmentation violation */
- {
- report_alarm( "alarm_segv: Oops, I just VIOLATED someones toes" );
- }
-
- static void alarm_sys() /* (*) bad argument to system call */
- {
- report_alarm( "alarm_sys: A system call does not like my parameters" );
- }
-
- static void alarm_pipe() /* write on a pipe with no one to read it */
- {
- report_alarm( "alarm_pipe: A pipe is a TWO way communication, remember ?" );
- }
-
- static void alarm_alrm() /* alarm clock timeout */
- {
- report_alarm( "alarm_alrm: The timer alarm is belling" );
- }
-
- static void alarm_term() /* software termination signal */
- {
- report_alarm( "alarm_term: Why should I terminate" );
- }
-
- static void alarm_cld() /* (+) sent to parent on child stop or exit */
- {
- report_alarm( "alarm_cld: Ohh, my child is dying" );
- }
-
- static void alarm_pwr() /* (+) power-fail restart */
- {
- report_alarm( "alarm_pwr: Who pulled the power cord ???" );
- }
-
- void catch_alarms()
- {
- char ident[] = "@(#) alarm.c 921014 catch_alarms(): Catch alarms and traps";
-
- signal( SIG_DFL, alarm_dfl );
- signal( SIGHUP, alarm_hup );
- signal( SIGINT, alarm_int );
- signal( SIGQUIT, alarm_quit );
- signal( SIGILL, alarm_ill );
- signal( SIGSEGV, alarm_segv );
- signal( SIGSYS, alarm_sys );
- signal( SIGPIPE, alarm_pipe );
- signal( SIGALRM, alarm_alrm );
- signal( SIGTERM, alarm_term );
- signal( SIGCHLD, alarm_cld );
- signal( SIGPWR, alarm_pwr );
-
-
- }
-
- main()
- {
- char ioarr[20], dummy[128];
- char ident[] = "@(#) alarm.c 921014 Test various alarms and traps";
- int status;
-
- catch_alarms();
-
- alarm( 60 );
- errno = 0;
- status = scanf( "%s", ioarr );
- if ( status != 1 ) {
- if (errno) {
- sprintf( dummy, "scanf status=%d, errno=%d, errmsg=%s", status, errno, strerror(errno) );
- }
- else {
- sprintf( dummy, "scanf status=%d", status );
- }
- report_alarm( dummy );
- }
- printf( "Input: %s<-\n", ioarr );
-
- }
-
-