Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
* sigsuspend() returns 111 on Alpha (repeatable, w/ source)
@ 2000-05-12  4:00 Eric Sorton
  2000-05-15  4:00 ` Roger Hill-Cottingham
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sorton @ 2000-05-12  4:00 UTC (permalink / raw)


Hi All,

My coworkers and I have found a case where sigsuspend() returns 111.  The
condition is repeatable using the code in this message.  This behavior
contradicts what is described in the manual page for sigsuspend().  According
to the manual page sigsuspend() should ALWAYS return -1; only errno should be
different.

The following highlights our configuration:

    o) Alpha ES40, I can provide more details if necessary.
    o) RedHat Linux 6.2.
    o) kernel 2.2.14 (RedHat package 2.2.14-6.0smp).
    o) glibc 2.1.3 (RedHat package 2.1.3-16).
    o) egcs 1.1.2 (RedHat package 1.1.2-30).

The program attached establishes a signal handler for SIGUSR2.  It enters a
while loop and calls sigsuspend().  It displays a message when the signal
handler is called and displays the return value of sigsuspend().  If you are
able to get this to repeat, please let me know as I am curious to see if it is
repeatable on a platform other than the ES40.

Depending on the location of the localtime(), the return value of sigsuspend()
will vary.  If localtime() is commented out, sigsuspend() will return 111.  If
localtime() is before the loop, sigsuspend() will return -1 the first time,
111 there after.  If localtime() is in the loop, sigsuspend() will always
return -1.  We found it odd that calling localtime() affected the return value
of sigsuspend :-)

For example:

viper% cc sigbug.c -o sigbug
viper% ./sigbug &
[2] 3691
viper% kill -USR2 %2
in sig handler, got sig 31
sigsuspend return is -1
viper% kill -USR2 %2
in sig handler, got sig 31
sigsuspend return is 111
viper% kill -USR2 %2
in sig handler, got sig 31
sigsuspend return is 111

Coincidentally, 111 corresponds to the syscall number for sigsuspend.

include/asm-alpha/unistd.h:#define __NR_sigsuspend              111

We ran the same source on an Intel/Linux box and the return value of
sigsuspend was always -1.

Eric Sorton <eric@cctcorp.com>
Command and Control Technologies

-----

#include <stdio.h>      /* perror(), printf() */
#include <signal.h>     /* sigfillset(), sigaction(), sigemptyset() */
                        /* sigaddset(), sigprocmask(), sigsuspend() */
#include <time.h>       /* time(), localtime() */

void SignalHandler(int sig) {
	printf("in sig handler, got sig %d\n", sig);
}

int main() {
	sigset_t allsigs;
	sigset_t blocksigs;
	struct sigaction act;
	int rtn;
	time_t t;
	struct tm *tp;

	sigfillset(&act.sa_mask);
	act.sa_handler = SignalHandler;
	act.sa_flags = 0;

	if (sigaction(SIGUSR2, &act, NULL) == -1) {
		perror("sigaction");
		return -1;
	}

	sigemptyset(&allsigs);
	sigemptyset(&blocksigs);

	if (sigaddset(&blocksigs, SIGUSR2) == -1) {
		perror("sigaddset");
		return -1;
	}

	if (sigprocmask(SIG_SETMASK, &blocksigs, NULL) == -1) {
		perror("sigprocmask");
		return -1;
	}

	t = time(NULL);

        /*
         * Comment/uncomment this line to change behavior of
         * the application.  If the line is commented out, then sending
         * SIGUSR2 to the process will cause the sigsuspend() below to return
         * with a 111.  If the line is uncommented, then sending SIGUSR2 to
         * the process will cause sigsuspend() below to return with a -1 the
         * first time, further SIGUSR2s will cause it to return with 111.
         */

	tp = localtime(&t);

	while (1) {
		rtn = sigsuspend(&allsigs);
		printf("sigsuspend return is %d\n", rtn);
	}

	return 0;
}



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sigsuspend() returns 111 on Alpha (repeatable, w/ source)
  2000-05-12  4:00 sigsuspend() returns 111 on Alpha (repeatable, w/ source) Eric Sorton
@ 2000-05-15  4:00 ` Roger Hill-Cottingham
  2000-05-16  4:00   ` Eric Sorton
  0 siblings, 1 reply; 3+ messages in thread
From: Roger Hill-Cottingham @ 2000-05-15  4:00 UTC (permalink / raw)


Eric Sorton wrote:
> 
> Hi All,
> 
> My coworkers and I have found a case where sigsuspend() returns 111.  The
> condition is repeatable using the code in this message.  This behavior
> contradicts what is described in the manual page for sigsuspend().  According
> to the manual page sigsuspend() should ALWAYS return -1; only errno should be
> different.
> 
> The following highlights our configuration:
> 
>     o) Alpha ES40, I can provide more details if necessary.
>     o) RedHat Linux 6.2.
>     o) kernel 2.2.14 (RedHat package 2.2.14-6.0smp).
>     o) glibc 2.1.3 (RedHat package 2.1.3-16).
>     o) egcs 1.1.2 (RedHat package 1.1.2-30).
> 
> The program attached establishes a signal handler for SIGUSR2.  It enters a
> while loop and calls sigsuspend().  It displays a message when the signal
> handler is called and displays the return value of sigsuspend().  If you are
> able to get this to repeat, please let me know as I am curious to see if it is
> repeatable on a platform other than the ES40.
> 
> Depending on the location of the localtime(), the return value of sigsuspend()
> will vary.  If localtime() is commented out, sigsuspend() will return 111.  If
> localtime() is before the loop, sigsuspend() will return -1 the first time,
> 111 there after.  If localtime() is in the loop, sigsuspend() will always
> return -1.  We found it odd that calling localtime() affected the return value
> of sigsuspend :-)
> 
> For example:
> 
> viper% cc sigbug.c -o sigbug
> viper% ./sigbug &
> [2] 3691
> viper% kill -USR2 %2
> in sig handler, got sig 31
> sigsuspend return is -1
> viper% kill -USR2 %2
> in sig handler, got sig 31
> sigsuspend return is 111
> viper% kill -USR2 %2
> in sig handler, got sig 31
> sigsuspend return is 111
> 
> Coincidentally, 111 corresponds to the syscall number for sigsuspend.
> 
> include/asm-alpha/unistd.h:#define __NR_sigsuspend              111
> 
> We ran the same source on an Intel/Linux box and the return value of
> sigsuspend was always -1.
> 
> Eric Sorton <eric@cctcorp.com>
> Command and Control Technologies
> 
> -----

<snip code>

I also get exactly this behaviour on an Alpha EB164 (Microway Screamer
500)
RH6.0, manually updated kernel 2.2.11, RH glibc-2.1.1-7, manually
compiled
egcs-1.1.2.

Regards,
Roger.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sigsuspend() returns 111 on Alpha (repeatable, w/ source)
  2000-05-15  4:00 ` Roger Hill-Cottingham
@ 2000-05-16  4:00   ` Eric Sorton
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Sorton @ 2000-05-16  4:00 UTC (permalink / raw)


Thanks ... at least now I know it is repeatable on different configurations.

A post to the alpha-libc mailing list provided no solution.  The only response
indicated that it is probably a kernel problem.  I'll try the kernel mailing
list next and post if a solution is found.

Eric

In article <391FFDB0.22A16175@bath.ac.uk>, Roger Hill-Cottingham wrote:
>
><snip code>
>
>I also get exactly this behaviour on an Alpha EB164 (Microway Screamer
>500)
>RH6.0, manually updated kernel 2.2.11, RH glibc-2.1.1-7, manually
>compiled
>egcs-1.1.2.
>
>Regards,
>Roger.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-05-16  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-05-12  4:00 sigsuspend() returns 111 on Alpha (repeatable, w/ source) Eric Sorton
2000-05-15  4:00 ` Roger Hill-Cottingham
2000-05-16  4:00   ` Eric Sorton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox