I've digged and digged around on the net for something that works, but can't find anything. The closest I've found is something like this:The siginfo_t parameter to sa_sigaction is a struct with the fo +llowing elements siginfo_t { int si_signo; /* Signal number */ int si_errno; /* An errno value */ int si_code; /* Signal code */ pid_t si_pid; /* Sending process ID */ uid_t si_uid; /* Real user ID of sending proce +ss */ int si_status; /* Exit value or signal */ clock_t si_utime; /* User time consumed */ clock_t si_stime; /* System time consumed */ sigval_t si_value; /* Signal value */ int si_int; /* POSIX.1b signal */ void * si_ptr; /* POSIX.1b signal */ void * si_addr; /* Memory location which caused +fault */ int si_band; /* Band event */ int si_fd; /* File descriptor */ }
However, it doesn't work on the Knoppix Linux distro that I tried. It acts like a typical $SIG trap, and doesn't return anything except the signal type.use POSIX; sub hup { print "hup(@_)\n"; for my $k (sort keys %{$_[1]}) { print "$k $_[1]->{$k}\n"; } } my $newaction=POSIX::SigAction->new(\&hup, 0, SA_SIGINFO); sigaction(SIGHUP, $newaction); print "I am $$\n"; kill HUP, $$;
Also, is there any reason why this sort of thing wouldn't be built into Perl in the first place? It would seem like a well requested thing to at least know which process ID sent a TERM signal, for example.
In reply to SIGINFO information in Perl by SineSwiper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |