… | |
… | |
171 | use common::sense; |
171 | use common::sense; |
172 | |
172 | |
173 | use base 'Exporter'; |
173 | use base 'Exporter'; |
174 | |
174 | |
175 | BEGIN { |
175 | BEGIN { |
176 | our $VERSION = 4.73; |
176 | our $VERSION = 4.76; |
177 | |
177 | |
178 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
178 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
179 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
179 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
180 | aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl |
180 | aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl |
181 | aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range |
181 | aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range |
… | |
… | |
280 | IO::AIO::nreqs |
280 | IO::AIO::nreqs |
281 | IO::AIO::nready |
281 | IO::AIO::nready |
282 | IO::AIO::npending |
282 | IO::AIO::npending |
283 | IO::AIO::reinit |
283 | IO::AIO::reinit |
284 | |
284 | |
285 | $nfd = IO::AIO::get_fdlimit [EXPERIMENTAL] |
285 | $nfd = IO::AIO::get_fdlimit |
286 | IO::AIO::min_fdlimit $nfd [EXPERIMENTAL] |
286 | IO::AIO::min_fdlimit $nfd |
287 | |
287 | |
288 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
288 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
289 | IO::AIO::fadvise $fh, $offset, $len, $advice |
289 | IO::AIO::fadvise $fh, $offset, $len, $advice |
290 | |
290 | |
291 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
291 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
… | |
… | |
2220 | |
2220 | |
2221 | =over 4 |
2221 | =over 4 |
2222 | |
2222 | |
2223 | =item $numfd = IO::AIO::get_fdlimit |
2223 | =item $numfd = IO::AIO::get_fdlimit |
2224 | |
2224 | |
2225 | This function is I<EXPERIMENTAL> and subject to change. |
|
|
2226 | |
|
|
2227 | Tries to find the current file descriptor limit and returns it, or |
2225 | Tries to find the current file descriptor limit and returns it, or |
2228 | C<undef> and sets C<$!> in case of an error. The limit is one larger than |
2226 | C<undef> and sets C<$!> in case of an error. The limit is one larger than |
2229 | the highest valid file descriptor number. |
2227 | the highest valid file descriptor number. |
2230 | |
2228 | |
2231 | =item IO::AIO::min_fdlimit [$numfd] |
2229 | =item IO::AIO::min_fdlimit [$numfd] |
2232 | |
|
|
2233 | This function is I<EXPERIMENTAL> and subject to change. |
|
|
2234 | |
2230 | |
2235 | Try to increase the current file descriptor limit(s) to at least C<$numfd> |
2231 | Try to increase the current file descriptor limit(s) to at least C<$numfd> |
2236 | by changing the soft or hard file descriptor resource limit. If C<$numfd> |
2232 | by changing the soft or hard file descriptor resource limit. If C<$numfd> |
2237 | is missing, it will try to set a very high limit, although this is not |
2233 | is missing, it will try to set a very high limit, although this is not |
2238 | recommended when you know the actual minimum that you require. |
2234 | recommended when you know the actual minimum that you require. |
… | |
… | |
2333 | C<IO::AIO::MAP_POPULATE>, |
2329 | C<IO::AIO::MAP_POPULATE>, |
2334 | C<IO::AIO::MAP_NONBLOCK>, |
2330 | C<IO::AIO::MAP_NONBLOCK>, |
2335 | C<IO::AIO::MAP_FIXED>, |
2331 | C<IO::AIO::MAP_FIXED>, |
2336 | C<IO::AIO::MAP_GROWSDOWN>, |
2332 | C<IO::AIO::MAP_GROWSDOWN>, |
2337 | C<IO::AIO::MAP_32BIT>, |
2333 | C<IO::AIO::MAP_32BIT>, |
2338 | C<IO::AIO::MAP_HUGETLB> or |
2334 | C<IO::AIO::MAP_HUGETLB>, |
2339 | C<IO::AIO::MAP_STACK>. |
2335 | C<IO::AIO::MAP_STACK>, |
|
|
2336 | C<IO::AIO::MAP_FIXED_NOREPLACE>, |
|
|
2337 | C<IO::AIO::MAP_SHARED_VALIDATE>, |
|
|
2338 | C<IO::AIO::MAP_SYNC> or |
|
|
2339 | C<IO::AIO::MAP_UNINITIALIZED>. |
2340 | |
2340 | |
2341 | If C<$fh> is C<undef>, then a file descriptor of C<-1> is passed. |
2341 | If C<$fh> is C<undef>, then a file descriptor of C<-1> is passed. |
2342 | |
2342 | |
2343 | C<$offset> is the offset from the start of the file - it generally must be |
2343 | C<$offset> is the offset from the start of the file - it generally must be |
2344 | a multiple of C<IO::AIO::PAGESIZE> and defaults to C<0>. |
2344 | a multiple of C<IO::AIO::PAGESIZE> and defaults to C<0>. |
… | |
… | |
2413 | truncated. |
2413 | truncated. |
2414 | |
2414 | |
2415 | To accept name-less sockets, use C<undef> for C<$sockaddr> and C<0> for |
2415 | To accept name-less sockets, use C<undef> for C<$sockaddr> and C<0> for |
2416 | C<$sockaddr_maxlen>. |
2416 | C<$sockaddr_maxlen>. |
2417 | |
2417 | |
2418 | The main reasons to use this syscall rather than portable C«accept(2)> |
2418 | The main reasons to use this syscall rather than portable C<accept(2)> |
2419 | are that you can specify C<SOCK_NONBLOCK> and/or C<SOCK_CLOEXEC> |
2419 | are that you can specify C<SOCK_NONBLOCK> and/or C<SOCK_CLOEXEC> |
2420 | flags and you can accept name-less sockets by specifying C<0> for |
2420 | flags and you can accept name-less sockets by specifying C<0> for |
2421 | C<$sockaddr_maxlen>, which is sadly not possible with perl's interface to |
2421 | C<$sockaddr_maxlen>, which is sadly not possible with perl's interface to |
2422 | C<accept>. |
2422 | C<accept>. |
2423 | |
2423 | |
… | |
… | |
2488 | C<IO::AIO::MFD_ALLOW_SEALING> and C<IO::AIO::MFD_HUGETLB>. |
2488 | C<IO::AIO::MFD_ALLOW_SEALING> and C<IO::AIO::MFD_HUGETLB>. |
2489 | |
2489 | |
2490 | Example: create a new memfd. |
2490 | Example: create a new memfd. |
2491 | |
2491 | |
2492 | my $fh = IO::AIO::memfd_create "somenameforprocfd", IO::AIO::MFD_CLOEXEC |
2492 | my $fh = IO::AIO::memfd_create "somenameforprocfd", IO::AIO::MFD_CLOEXEC |
2493 | or die "m,emfd_create: $!\n"; |
2493 | or die "memfd_create: $!\n"; |
|
|
2494 | |
|
|
2495 | =item $fh = IO::AIO::pidfd_open $pid[, $flags] |
|
|
2496 | |
|
|
2497 | This is an interface to the Linux L<pidfd_open(2)> system call. The |
|
|
2498 | default for C<$flags> is C<0>. |
|
|
2499 | |
|
|
2500 | On success, a new pidfd filehandle is returned (that is already set to |
|
|
2501 | close-on-exec), otherwise returns C<undef>. If the syscall is missing, |
|
|
2502 | fails with C<ENOSYS>. |
|
|
2503 | |
|
|
2504 | Example: open pid 6341 as pidfd. |
|
|
2505 | |
|
|
2506 | my $fh = IO::AIO::pidfd_open 6341 |
|
|
2507 | or die "pidfd_open: $!\n"; |
|
|
2508 | |
|
|
2509 | =item $status = IO::AIO::pidfd_send_signal $pidfh, $signal[, $siginfo[, $flags]] |
|
|
2510 | |
|
|
2511 | This is an interface to the Linux L<pidfd_send_signal> system call. The |
|
|
2512 | default for C<$siginfo> is C<undef> and the default for C<$flags> is C<0>. |
|
|
2513 | |
|
|
2514 | Returns the system call status. If the syscall is missing, fails with |
|
|
2515 | C<ENOSYS>. |
|
|
2516 | |
|
|
2517 | When specified, C<$siginfo> must be a reference to a hash with one or more |
|
|
2518 | of the following members: |
|
|
2519 | |
|
|
2520 | =over |
|
|
2521 | |
|
|
2522 | =item code - the C<si_code> member |
|
|
2523 | |
|
|
2524 | =item pid - the C<si_pid> member |
|
|
2525 | |
|
|
2526 | =item uid - the C<si_uid> member |
|
|
2527 | |
|
|
2528 | =item value_int - the C<si_value.sival_int> member |
|
|
2529 | |
|
|
2530 | =item value_ptr - the C<si_value.sival_ptr> member, specified as an integer |
|
|
2531 | |
|
|
2532 | =back |
|
|
2533 | |
|
|
2534 | Example: send a SIGKILL to the specified process. |
|
|
2535 | |
|
|
2536 | my $status = IO::AIO::pidfd_send_signal $pidfh, 9, undef |
|
|
2537 | and die "pidfd_send_signal: $!\n"; |
|
|
2538 | |
|
|
2539 | Example: send a SIGKILL to the specified process with extra data. |
|
|
2540 | |
|
|
2541 | my $status = IO::AIO::pidfd_send_signal $pidfh, 9, { code => -1, value_int => 7 } |
|
|
2542 | and die "pidfd_send_signal: $!\n"; |
|
|
2543 | |
|
|
2544 | =item $fh = IO::AIO::pidfd_getfd $pidfh, $targetfd[, $flags] |
|
|
2545 | |
|
|
2546 | This is an interface to the Linux L<pidfd_getfd> system call. The default |
|
|
2547 | for C<$flags> is C<0>. |
|
|
2548 | |
|
|
2549 | On success, returns a dup'ed copy of the target file descriptor (specified |
|
|
2550 | as an integer) returned (that is already set to close-on-exec), otherwise |
|
|
2551 | returns C<undef>. If the syscall is missing, fails with C<ENOSYS>. |
|
|
2552 | |
|
|
2553 | Example: get a copy of standard error of another process and print soemthing to it. |
|
|
2554 | |
|
|
2555 | my $errfh = IO::AIO::pidfd_getfd $pidfh, 2 |
|
|
2556 | or die "pidfd_getfd: $!\n"; |
|
|
2557 | print $errfh "stderr\n"; |
|
|
2558 | |
2494 | =item $fh = IO::AIO::eventfd [$initval, [$flags]] |
2559 | =item $fh = IO::AIO::eventfd [$initval, [$flags]] |
2495 | |
2560 | |
2496 | This is a direct interface to the Linux L<eventfd(2)> system call. The |
2561 | This is a direct interface to the Linux L<eventfd(2)> system call. The |
2497 | (unhelpful) defaults for C<$initval> and C<$flags> are C<0> for both. |
2562 | (unhelpful) defaults for C<$initval> and C<$flags> are C<0> for both. |
2498 | |
2563 | |