[comp.lang.c] System V function calls to signal

duvalj@bionette.cgrb.orst.edu (Joe Duval - Entomology) (11/16/89)

Hi,
  I would like some help using the signal function on a SYSV machine.  I am
using an AT&T 3b2. Here is what I want to do.
	I want to catch the action previously defined for a signal, lets say
	SIGINT, so I can reset that action later.  After I catch the previous
	action, I want to do something else and then call signal again to reset
	the previous action.  Redundant, huh?
	I have tried signal and ssignal both with no luck.  I am sure that is
	in my logic.

Any help will be appreciated.  I have included two pieces of code; one uses
signal and the next uses ssignal.

Here is my (attempt at) code USES SIGNAL:

#include <signal.h>

static Foo()
{
	static int (*sigint)();
	int catch_int();
    /* First I want to catch the action previously established for that
     * signal type */
     sigint = signal (SIGINT, catch_int);  /* An invalid pointer combination 
				   	      error occurs here. */ 

    /* Then I want to do something else, go kill a process in this case */ 
     kill(getpid(), SIGINT); 
     
    /*  Now I want to return to the previous action to that signal type */ 
     signal (SIGINT, sigint); } static catch_int(n) {
}


Here is my attempt at the code USING SSIGNAL:

#include <signal.h>

static Foo()
{
	static int (*sigint)();
	int catch_int();

      /*  In <signal.h>  ssignal is defined like this 
		int (*ssignal (sig, action))()
		int sig, (*action)();
       */

	sigint = (*)ssignal (SIGINT, catch_int);

	kill(getpid(), SIGINT);

	signal (SIGINT, sigint);
}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
duvalj@bionette.cgrb.orst.edu.UUCP      | Life is a tragedy for those that feel
jozo@aes.orst.edu.UUCP                  | and a comedy for those that think!
Phone: (503) 757-1297			|
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
duvalj@bionette.cgrb.orst.edu.UUCP      | Life is a tragedy for those that feel
jozo@aes.orst.edu.UUCP                  | and a comedy for those that think!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

gwyn@smoke.BRL.MIL (Doug Gwyn) (11/16/89)

In article <13842@orstcs.CS.ORST.EDU> duvalj@bionette.cgrb.orst.edu.UUCP (Joe Duval - Entomology) writes:
>	I have tried signal and ssignal both with no luck.  I am sure that is
>	in my logic.

Your signal()-using program was essentially correct, except you should
be aware that modern signal handlers return void, not int.

Forget ssignal()/gsignal(); you shouldn't try using those for ANYthing.

jeenglis@nunki.usc.edu (Joe English) (11/17/89)

gwyn@brl.arpa (Doug Gwyn) writes:
>
>Forget ssignal()/gsignal(); you shouldn't try using those for ANYthing.

What are ssignal() and gsignal() for, anyway?
Are they part of the ANSI standard library?


--Joe English

  jeenglis@nunki.usc.edu

gwyn@smoke.BRL.MIL (Doug Gwyn) (11/17/89)

In article <6542@merlin.usc.edu> jeenglis@nunki.usc.edu (Joe English) writes:
>What are ssignal() and gsignal() for, anyway?

I think they showed up in UNIX System III, certainly UNIX System V.
They're just a software analog of the signal() facility.

>Are they part of the ANSI standard library?

Heavens, no.

dan@charyb.COM (Dan Mick) (11/18/89)

The Turbo C manual claims they're old (System III?) versions of software
signal handling and delivering.  TC 2.0 dropped them in favor of signal(),
and included code for rolling your own if you really really needed them.
-- 
.sig files are idiotic and wasteful.

prc@erbe.se (Robert Claeson) (11/19/89)

In article <11625@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> In article <6542@merlin.usc.edu> jeenglis@nunki.usc.edu (Joe English) writes:
> >What are ssignal() and gsignal() for, anyway?
> 
> I think they showed up in UNIX System III, certainly UNIX System V.
> They're just a software analog of the signal() facility.

The SVID don't recommend you to use them. They are subject of removal in
future releases of System V.

-- 
          Robert Claeson      E-mail: rclaeson@erbe.se
	  ERBE DATA AB