[comp.unix.aux] AUX, signal, and sigvec

schiebel@cs.wvu.wvnet.edu (Darrell Schiebel) (05/03/91)

I am tring to get signal trapping working on some code I'm porting to AUX.
Here is the code I'm using (the entire code is at the end of message):

	svec.sv_flags = 0;
	svec.sv_mask = 0xffffff;
	svec.sv_handler = catcher;
	if (sigvec(2,&svec,0) == -1){

Where "catcher" is the signal handler. I`ve tried other things for the
"sv_mask",0 and 2. Does the mask indicate signals which get passed to
handlers or signals which do not get passed? At any rate, the above code 
works when compiled on Suns but not when compiled on A/UX. I get the error 
invalid argument when I make the call to sigvec. Any suggestions?

The "signal" works both on Sun and A/UX (attesting to its portablility). So 
why not use signal? In the A/UX man pages it sayes that the only thing passed
to the signal handler is the signal id. I need to have more information than
this, i.e. the information provided by "sigvec":

	ghandle (sig, code, scp)
	  int sig, code;
	  struct sigcontext *scp;

I'd appreciate any information anyone could provide. Also on the Sun, using
signal instead of sigvec, the handler gets called with each signal sent with
"kill", but under A/UX the process dies with the second signal. Do I need to
reset something. Suns are very forgiving.


						Many Thanks,
						Darrell Schiebel
						(schiebel@a.cs.wvu.wvnet.edu)
						(drs@baks.bell-atl.com)


--X--X--X--X--X--X--X--X--X--X--X--X--X--X--X--X--X--
#include <signal.h>
#include <errno.h>
#include <stdio.h>

int catcher(){
  printf("in catcher\n");}

main(){
  struct sigvec svec;

  svec.sv_flags = 0;
  svec.sv_mask = 0xffffff;
  svec.sv_handler = catcher;

/*  signal(2,catcher);*/
  if (sigvec(2,&svec,0) == -1){
    perror("main");
    switch(errno){
      case EFAULT:
        printf("EFAULT\n");
        break;
      case EINVAL:
        printf("EINVAL\n");
        break;}
    exit(1);}
  while (! feof(stdin));}

tody@noao.edu (Doug Tody NOAO/IRAF CCS) (05/06/91)

From article <1497@h.cs.wvu.wvnet.edu>, by schiebel@cs.wvu.wvnet.edu (Darrell Schiebel):
> I am tring to get signal trapping working on some code I'm porting to AUX.
> Here is the code I'm using (the entire code is at the end of message):
> 
> 	svec.sv_flags = 0;
> 	svec.sv_mask = 0xffffff;
> 	svec.sv_handler = catcher;
> 	if (sigvec(2,&svec,0) == -1){
> 
> Where "catcher" is the signal handler. I`ve tried other things for the
> "sv_mask",0 and 2. Does the mask indicate signals which get passed to
> handlers or signals which do not get passed? At any rate, the above code 
> works when compiled on Suns but not when compiled on A/UX. I get the error 
> invalid argument when I make the call to sigvec. Any suggestions?

By chance I had much the same problem the other day...  Executing the
following code during process startup made the problem go away (sigvec is
a BSD system call):

	#include <compat.h>
	setcompat (COMPAT_BSD);

The tells the kernel to use BSD semantics for the A/UX system calls, instead
of SVID, which is the default (actually the call shown affects more than
just the signal stuff, but that is probably what you want if you are porting
from a Sun).
-- 
Doug Tody, National Optical Astronomy Observatories, Tucson AZ, 602-325-9217
UUCP: {arizona,decvax,ncar}!noao!tody  or  uunet!noao.edu!tody 
Internet: tody@noao.edu             SPAN/HEPNET: NOAO::TODY (NOAO=5355)