--- IO-AIO/README 2020/12/04 01:19:58 1.65 +++ IO-AIO/README 2020/12/29 15:20:12 1.66 @@ -1906,11 +1906,11 @@ To accept name-less sockets, use "undef" for $sockaddr and 0 for $sockaddr_maxlen. - The main reasons to use this syscall rather than portable - C«accept(2)> are that you can specify "SOCK_NONBLOCK" and/or - "SOCK_CLOEXEC" flags and you can accept name-less sockets by - specifying 0 for $sockaddr_maxlen, which is sadly not possible with - perl's interface to "accept". + The main reasons to use this syscall rather than portable accept(2) + are that you can specify "SOCK_NONBLOCK" and/or "SOCK_CLOEXEC" flags + and you can accept name-less sockets by specifying 0 for + $sockaddr_maxlen, which is sadly not possible with perl's interface + to "accept". IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags Calls the GNU/Linux splice(2) syscall, if available. If $r_off or @@ -1978,9 +1978,65 @@ Example: create a new memfd. my $fh = IO::AIO::memfd_create "somenameforprocfd", IO::AIO::MFD_CLOEXEC - or die "m,emfd_create: $!\n"; - =item $fh = IO::AIO::eventfd [$initval, [$flags]] + or die "memfd_create: $!\n"; + $fh = IO::AIO::pidfd_open $pid[, $flags] + This is an interface to the Linux pidfd_open(2) system call. The + default for $flags is 0. + + On success, a new pidfd filehandle is returned (that is already set + to close-on-exec), otherwise returns "undef". If the syscall is + missing, fails with "ENOSYS". + + Example: open pid 6341 as pidfd. + + my $fh = IO::AIO::pidfd_open 6341 + or die "pidfd_open: $!\n"; + + $status = IO::AIO::pidfd_send_signal $pidfh, $signal[, $siginfo[, + $flags]] + This is an interface to the Linux pidfd_send_signal system call. The + default for $siginfo is "undef" and the default for $flags is 0. + + Returns the system call status. If the syscall is missing, fails + with "ENOSYS". + + When specified, $siginfo must be a reference to a hash with one or + more of the following members: + + code - the "si_code" member + pid - the "si_pid" member + uid - the "si_uid" member + value_int - the "si_value.sival_int" member + value_ptr - the "si_value.sival_ptr" member, specified as an integer + + Example: send a SIGKILL to the specified process. + + my $status = IO::AIO::pidfd_send_signal $pidfh, 9, undef + and die "pidfd_send_signal: $!\n"; + + Example: send a SIGKILL to the specified process with extra data. + + my $status = IO::AIO::pidfd_send_signal $pidfh, 9, { code => -1, value_int => 7 } + and die "pidfd_send_signal: $!\n"; + + $fh = IO::AIO::pidfd_getfd $pidfh, $targetfd[, $flags] + This is an interface to the Linux pidfd_getfd system call. The + default for $flags is 0. + + On success, returns a dup'ed copy of the target file descriptor + (specified as an integer) returned (that is already set to + close-on-exec), otherwise returns "undef". If the syscall is + missing, fails with "ENOSYS". + + Example: get a copy of standard error of another process and print + soemthing to it. + + my $errfh = IO::AIO::pidfd_getfd $pidfh, 2 + or die "pidfd_getfd: $!\n"; + print $errfh "stderr\n"; + + $fh = IO::AIO::eventfd [$initval, [$flags]] This is a direct interface to the Linux eventfd(2) system call. The (unhelpful) defaults for $initval and $flags are 0 for both.