home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7079 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  1.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!ka.reg.uci.edu!bmarlowe
  2. From: bmarlowe@ka.reg.uci.edu (Brett Marlowe)
  3. Subject: syscall arguments: Can't seem to get 'em to work
  4. Nntp-Posting-Host: ka.reg.uci.edu
  5. Message-ID: <bmarlowe.722292146@ka>
  6. Summary: Having trouble returning value through pointer to integer argument
  7. Newsgroups: comp.lang.perl
  8. Keywords: syscall int* argument
  9. Lines: 57
  10. Distribution: usa
  11. Date: 20 Nov 92 20:51:52 GMT
  12.  
  13. I am developing an interface to the advanced signal handling
  14. facilities.
  15.  
  16. SunOS 4.1.1
  17. SPARCstation 2 (sun4c)
  18.  
  19. This is perl, version 4.0
  20.  
  21. $RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
  22. Patch level: 19
  23.  
  24. Copyright (c) 1989, 1990, 1991, Larry Wall
  25.  
  26. Perl may be copied only under the terms of either the Artistic License or the
  27. GNU General Public License, which may be found in the Perl 4.0 source kit.
  28.  
  29.  
  30. The following program should print:
  31.  
  32. Sleeping...^C
  33. 00000002
  34. SIGINT
  35.  
  36. but it prints:
  37.  
  38. Sleeping...^C
  39. 00000000
  40. SIGINT
  41.  
  42. Can anybody tell me what I'm doing wrong?  I wrote the equivalent
  43. program in C and it worked just fine.  It appears that the syscall is
  44. not placing the sigmask in the string buffer.  I think it may be that
  45. the system call has a library wrapper, but I can't seem to figure out
  46. how to check.
  47.  
  48.  
  49. #!/usr/bin/perl
  50.  
  51. $| = 1;
  52. $SIG{'INT'} = 'sig_handler';
  53. sub sig_handler { print "SIG$_[0]\n"; }
  54.  
  55. $sm = syscall(&SYS_sigblock,2);
  56. print "Sleeping...";
  57. sleep 5;    # press control-c during this sleep
  58. print "\n";
  59.  
  60. $sigmask = pack("I",0);
  61. syscall(&SYS_sigpending,$sigmask) == 0 || die $!;
  62. printf("%08x\n",$sigmask);
  63.  
  64. syscall(&SYS_sigsetmask,$sm);
  65.  
  66. --
  67. -------------------------------------------------------------------------------
  68. Brett Marlowe    |  University of California, Irvine
  69. bmarlowe@uci.edu |  Office of the Registrar  (making sure you get your bills)
  70.