Google Groups Home
Help | Sign in
Message from discussion Сигналы: 20 лет в тумане
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Lev Walkin  
View profile
 More options Jul 3 2003, 7:24 am
Newsgroups: fido7.ru.unix.prog
From: Lev Walkin <v...@netli.com>
Date: Thu, 3 Jul 2003 11:24:16 +0000 (UTC)
Local: Thurs, Jul 3 2003 7:24 am
Subject: Re: Сигналы: 20 лет в тумане

Mykola Dzham wrote:
>  Yar Tikhiy (y...@comp.chem.msu.su):

>>Правило 3

>>Существует ровно один тип статических данных, sig_atomic_t, переменную
>>которого обработчик сигнала может установить.  Поведение приложения
>>неопределено, если обработчик сигнала обращается к статическим
>>данным любым другим способом.

> А вот если делать обработчик сигнала например в перловом скрипте,
> то как там с подобным ограничением поступать?

Plug and pray...
Хорошо, что Perl не работает на моем тостере.

=== pl source code ===
$SIG{'ALRM'} = \&handler;

$\="\n";

alarm(1);
sleep(2);
alarm(1);
sleep(2);

print 'exit';

sub handler() {
         print 'alarm';

}

=== pl source code ===

=== ktrace perl pl ===
   2694 perl     CALL  nanosleep(0xbfbff668,0xbfbff660)
   2694 perl     PSIG  SIGALRM caught handler=0x280be470 mask=0x0 code=0x0
   2694 perl     RET   nanosleep -1 errno 4 Interrupted system call
   2694 perl     CALL  fstat(0x1,0xbfbff1a4)
   2694 perl     RET   fstat 0
   2694 perl     CALL  ioctl(0x1,TIOCGETA,0xbfbff1d8)
   2694 perl     RET   ioctl 0
   2694 perl     CALL  write(0x1,0x805c000,0x6)
   2694 perl     GIO   fd 1 wrote 6 bytes
        "alarm
        "
   2694 perl     RET   write 6
   2694 perl     CALL  sigreturn(0xbfbff4b0)
   2694 perl     RET   sigreturn JUSTRETURN
   2694 perl     CALL  gettimeofday(0xbfbff668,0)
   2694 perl     RET   gettimeofday 0
   2694 perl     CALL  setitimer(0,0xbfbff670,0xbfbff660)
   2694 perl     RET   setitimer 0
   2694 perl     CALL  gettimeofday(0xbfbff668,0)
   2694 perl     RET   gettimeofday 0
   2694 perl     CALL  nanosleep(0xbfbff668,0xbfbff660)
   2694 perl     PSIG  SIGALRM caught handler=0x280be470 mask=0x0 code=0x0
   2694 perl     RET   nanosleep -1 errno 4 Interrupted system call
   2694 perl     CALL  write(0x1,0x805c000,0x6)
   2694 perl     GIO   fd 1 wrote 6 bytes
        "alarm
        "
   2694 perl     RET   write 6
   2694 perl     CALL  sigreturn(0xbfbff4b0)
   2694 perl     RET   sigreturn JUSTRETURN
   2694 perl     CALL  gettimeofday(0xbfbff668,0)
   2694 perl     RET   gettimeofday 0
   2694 perl     CALL  write(0x1,0x805c000,0x5)
   2694 perl     GIO   fd 1 wrote 5 bytes
        "exit
        "
=== kdump ===

=== gdb'ing perl ===
[vlm@spelio:~]>gdb perl
GNU gdb 4.18 (FreeBSD)
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-freebsd"...(no debugging symbols
found)...
(gdb) br 0x280be470
Function "0x280be470" not defined.
(gdb) br main
Breakpoint 1 at 0x8048dfb
(gdb) run pl
Starting program: /usr/bin/perl pl
(no debugging symbols found)...(no debugging symbols found)...(no debugging
symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...(no debugging
symbols found)...
Breakpoint 1, 0x8048dfb in main ()
(gdb) br *(0x280be470)
Breakpoint 2 at 0x280be470
(gdb) cont
Continuing.

Breakpoint 2, 0x280be470 in Perl_sighandler () from /usr/lib/libperl.so.3
(gdb)
=== end of gdb'ing perl ===

=== Perl_sighandler from Perl's sources ===
     PUSHSTACKi(PERLSI_SIGNAL);
     PUSHMARK(SP);
     PUSHs(sv);
     PUTBACK;

     call_sv((SV*)cv, G_DISCARD);

     POPSTACK;
cleanup:
     if (flags & 1)
         PL_savestack_ix -= 8; /* Unprotect save in progress. */
     if (flags & 4)
         PL_markstack_ptr--;
     if (flags & 8)
         PL_retstack_ix--;
     if (flags & 16)
         PL_scopestack_ix -= 1;
     if (flags & 64)
         SvREFCNT_dec(sv);
     PL_op = myop;                       /* Apparently not needed... */
=== end of Perl sources ===

--
Lev Walkin
v...@netli.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google