.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "IO::Async::OS 3pm" .TH IO::Async::OS 3pm "2014-10-21" "perl v5.20.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" "IO::Async::OS" \- operating system abstractions for "IO::Async" .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module acts as a class to provide a number of utility methods whose exact behaviour may depend on the type of \s-1OS\s0 it is running on. It is provided as a class so that specific kinds of operating system can override methods in it. .PP As well as these support functions it also provides a number of constants, all with names beginning \f(CW\*(C`HAVE_\*(C'\fR which describe various features that may or may not be available on the \s-1OS\s0 or perl build. Most of these are either hard-coded per \s-1OS,\s0 or detected at runtime. .PP The following constants may be overridden by environment variables. .IP "\(bu" 4 \&\s-1HAVE_POSIX_FORK\s0 .Sp True if the \f(CW\*(C`fork()\*(C'\fR call has full \s-1POSIX\s0 semantics (full process separation). This is true on most OSes but false on MSWin32. .Sp This may be overridden to be false by setting the environment variable \&\f(CW\*(C`IO_ASYNC_NO_FORK\*(C'\fR. .IP "\(bu" 4 \&\s-1HAVE_THREADS\s0 .Sp True if \f(CW\*(C`ithreads\*(C'\fR are available, meaning that the \f(CW\*(C`threads\*(C'\fR module can be used. This depends on whether perl was built with threading support. .Sp This may be overridable to be false by setting the environment variable \&\f(CW\*(C`IO_ASYNC_NO_THREADS\*(C'\fR. .ie n .SS "$family = IO::Async::OS\->getfamilybyname( $name )" .el .SS "\f(CW$family\fP = IO::Async::OS\->getfamilybyname( \f(CW$name\fP )" .IX Subsection "$family = IO::Async::OS->getfamilybyname( $name )" Return a protocol family value based on the given name. If \f(CW$name\fR looks like a number it will be returned as-is. The string values \f(CW\*(C`inet\*(C'\fR, \f(CW\*(C`inet6\*(C'\fR and \&\f(CW\*(C`unix\*(C'\fR will be converted to the appropriate \f(CW\*(C`AF_*\*(C'\fR constant. .ie n .SS "$socktype = IO::Async::OS\->getsocktypebyname( $name )" .el .SS "\f(CW$socktype\fP = IO::Async::OS\->getsocktypebyname( \f(CW$name\fP )" .IX Subsection "$socktype = IO::Async::OS->getsocktypebyname( $name )" Return a socket type value based on the given name. If \f(CW$name\fR looks like a number it will be returned as-is. The string values \f(CW\*(C`stream\*(C'\fR, \f(CW\*(C`dgram\*(C'\fR and \&\f(CW\*(C`raw\*(C'\fR will be converted to the appropriate \f(CW\*(C`SOCK_*\*(C'\fR constant. .ie n .SS "( $S1, $S2 ) = IO::Async::OS\->socketpair( $family, $socktype, $proto )" .el .SS "( \f(CW$S1\fP, \f(CW$S2\fP ) = IO::Async::OS\->socketpair( \f(CW$family\fP, \f(CW$socktype\fP, \f(CW$proto\fP )" .IX Subsection "( $S1, $S2 ) = IO::Async::OS->socketpair( $family, $socktype, $proto )" An abstraction of the \f(CWsocketpair(2)\fR syscall, where any argument may be missing (or given as \f(CW\*(C`undef\*(C'\fR). .PP If \f(CW$family\fR is not provided, a suitable value will be provided by the \s-1OS \&\s0(likely \f(CW\*(C`AF_UNIX\*(C'\fR on POSIX-based platforms). If \f(CW$socktype\fR is not provided, then \f(CW\*(C`SOCK_STREAM\*(C'\fR will be used. .PP Additionally, this method supports building connected \f(CW\*(C`SOCK_STREAM\*(C'\fR or \&\f(CW\*(C`SOCK_DGRAM\*(C'\fR pairs in the \f(CW\*(C`AF_INET\*(C'\fR family even if the underlying platform's \&\f(CWsocketpair(2)\fR does not, by connecting two normal sockets together. .PP \&\f(CW$family\fR and \f(CW$socktype\fR may also be given symbolically as defined by \&\f(CW\*(C`getfamilybyname\*(C'\fR and \f(CW\*(C`getsocktypebyname\*(C'\fR. .ie n .SS "( $rd, $wr ) = IO::Async::OS\->pipepair" .el .SS "( \f(CW$rd\fP, \f(CW$wr\fP ) = IO::Async::OS\->pipepair" .IX Subsection "( $rd, $wr ) = IO::Async::OS->pipepair" An abstraction of the \f(CWpipe(2)\fR syscall, which returns the two new handles. .ie n .SS "( $rdA, $wrA, $rdB, $wrB ) = IO::Async::OS\->pipequad" .el .SS "( \f(CW$rdA\fP, \f(CW$wrA\fP, \f(CW$rdB\fP, \f(CW$wrB\fP ) = IO::Async::OS\->pipequad" .IX Subsection "( $rdA, $wrA, $rdB, $wrB ) = IO::Async::OS->pipequad" This method is intended for creating two pairs of filehandles that are linked together, suitable for passing as the \s-1STDIN/STDOUT\s0 pair to a child process. After this function returns, \f(CW$rdA\fR and \f(CW$wrA\fR will be a linked pair, as will \f(CW$rdB\fR and \f(CW$wrB\fR. .PP On platforms that support \f(CWsocketpair(2)\fR, this implementation will be preferred, in which case \f(CW$rdA\fR and \f(CW$wrB\fR will actually be the same filehandle, as will \f(CW$rdB\fR and \f(CW$wrA\fR. This saves a file descriptor in the parent process. .PP When creating a \f(CW\*(C`IO::Async::Stream\*(C'\fR or subclass of it, the \f(CW\*(C`read_handle\*(C'\fR and \f(CW\*(C`write_handle\*(C'\fR parameters should always be used. .PP .Vb 1 \& my ( $childRd, $myWr, $myRd, $childWr ) = IO::Async::OS\->pipequad; \& \& IO::Async::OS\->open_child( \& stdin => $childRd, \& stdout => $childWr, \& ... \& ); \& \& my $str = IO::Async::Stream\->new( \& read_handle => $myRd, \& write_handle => $myWr, \& ... \& ); \& IO::Async::OS\->add( $str ); .Ve .ie n .SS "$signum = IO::Async::OS\->signame2num( $signame )" .el .SS "\f(CW$signum\fP = IO::Async::OS\->signame2num( \f(CW$signame\fP )" .IX Subsection "$signum = IO::Async::OS->signame2num( $signame )" This utility method converts a signal name (such as \*(L"\s-1TERM\*(R"\s0) into its system\- specific signal number. This may be useful to pass to \f(CW\*(C`POSIX::SigSet\*(C'\fR or use in other places which use numbers instead of symbolic names. .ie n .SS "( $family, $socktype, $protocol, $addr ) = IO::Async::OS\->extract_addrinfo( $ai )" .el .SS "( \f(CW$family\fP, \f(CW$socktype\fP, \f(CW$protocol\fP, \f(CW$addr\fP ) = IO::Async::OS\->extract_addrinfo( \f(CW$ai\fP )" .IX Subsection "( $family, $socktype, $protocol, $addr ) = IO::Async::OS->extract_addrinfo( $ai )" Given an \s-1ARRAY\s0 or \s-1HASH\s0 reference value containing an addrinfo, returns a family, socktype and protocol argument suitable for a \f(CW\*(C`socket\*(C'\fR call and an address suitable for \f(CW\*(C`connect\*(C'\fR or \f(CW\*(C`bind\*(C'\fR. .PP If given an \s-1ARRAY\s0 it should be in the following form: .PP .Vb 1 \& [ $family, $socktype, $protocol, $addr ] .Ve .PP If given a \s-1HASH\s0 it should contain the following keys: .PP .Vb 1 \& family socktype protocol addr .Ve .PP Each field in the result will be initialised to 0 (or empty string for the address) if not defined in the \f(CW$ai\fR value. .PP The family type may also be given as a symbolic string as defined by \&\f(CW\*(C`getfamilybyname\*(C'\fR. .PP The socktype may also be given as a symbolic string; \f(CW\*(C`stream\*(C'\fR, \f(CW\*(C`dgram\*(C'\fR or \&\f(CW\*(C`raw\*(C'\fR; this will be converted to the appropriate \f(CW\*(C`SOCK_*\*(C'\fR constant. .PP Note that the \f(CW\*(C`addr\*(C'\fR field, if provided, must be a packed socket address, such as returned by \f(CW\*(C`pack_sockaddr_in\*(C'\fR or \f(CW\*(C`pack_sockaddr_un\*(C'\fR. .PP If the \s-1HASH\s0 form is used, rather than passing a packed socket address in the \&\f(CW\*(C`addr\*(C'\fR field, certain other hash keys may be used instead for convenience on certain named families. .IP "family => 'inet'" 4 .IX Item "family => 'inet'" Will pack an \s-1IP\s0 address and port number from keys called \f(CW\*(C`ip\*(C'\fR and \f(CW\*(C`port\*(C'\fR. If \f(CW\*(C`ip\*(C'\fR is missing it will be set to \*(L"0.0.0.0\*(R". If \f(CW\*(C`port\*(C'\fR is missing it will be set to 0. .IP "family => 'inet6'" 4 .IX Item "family => 'inet6'" Will pack an \s-1IP\s0 address and port number from keys called \f(CW\*(C`ip\*(C'\fR and \f(CW\*(C`port\*(C'\fR. If \f(CW\*(C`ip\*(C'\fR is missing it will be set to \*(L"::\*(R". If \f(CW\*(C`port\*(C'\fR is missing it will be set to 0. Optionally will also include values from \f(CW\*(C`scopeid\*(C'\fR and \f(CW\*(C`flowinfo\*(C'\fR keys if provided. .Sp This will only work if a \f(CW\*(C`pack_sockaddr_in6\*(C'\fR function can be found in \&\f(CW\*(C`Socket\*(C'\fR .IP "family => 'unix'" 4 .IX Item "family => 'unix'" Will pack a \s-1UNIX\s0 socket path from a key called \f(CW\*(C`path\*(C'\fR. .SH "LOOP IMPLEMENTATION METHODS" .IX Header "LOOP IMPLEMENTATION METHODS" The following methods are provided on \f(CW\*(C`IO::Async::OS\*(C'\fR because they are likely to require OS-specific implementations, but are used by IO::Async::Loop to implement its functionality. It can use the \s-1HASH\s0 reference \f(CW\*(C`$loop\->{os}\*(C'\fR to store other data it requires. .ie n .SS "IO::Async::OS\->loop_watch_signal( $loop, $signal, $code )" .el .SS "IO::Async::OS\->loop_watch_signal( \f(CW$loop\fP, \f(CW$signal\fP, \f(CW$code\fP )" .IX Subsection "IO::Async::OS->loop_watch_signal( $loop, $signal, $code )" .ie n .SS "IO::Async::OS\->loop_unwatch_signal( $loop, $signal )" .el .SS "IO::Async::OS\->loop_unwatch_signal( \f(CW$loop\fP, \f(CW$signal\fP )" .IX Subsection "IO::Async::OS->loop_unwatch_signal( $loop, $signal )" Used to implement the \f(CW\*(C`watch_signal\*(C'\fR / \f(CW\*(C`unwatch_signal\*(C'\fR Loop pair. .ie n .SS "@fds = IO::Async::OS\->potentially_open_fds" .el .SS "\f(CW@fds\fP = IO::Async::OS\->potentially_open_fds" .IX Subsection "@fds = IO::Async::OS->potentially_open_fds" Returns a list of filedescriptors which might need closing. By default this will return \f(CW\*(C`0 .. _SC_OPEN_MAX\*(C'\fR. OS-specific subclasses may have a better guess. .SH "AUTHOR" .IX Header "AUTHOR" Paul Evans