… | |
… | |
1085 | To support fork in your programs, you either have to call |
1085 | To support fork in your programs, you either have to call |
1086 | C<ev_default_fork ()> or C<ev_loop_fork ()> after a fork in the child, |
1086 | C<ev_default_fork ()> or C<ev_loop_fork ()> after a fork in the child, |
1087 | enable C<EVFLAG_FORKCHECK>, or resort to C<EVBACKEND_SELECT> or |
1087 | enable C<EVFLAG_FORKCHECK>, or resort to C<EVBACKEND_SELECT> or |
1088 | C<EVBACKEND_POLL>. |
1088 | C<EVBACKEND_POLL>. |
1089 | |
1089 | |
|
|
1090 | =head3 The special problem of SIGPIPE |
|
|
1091 | |
|
|
1092 | While not really specific to libev, it is easy to forget about SIGPIPE: |
|
|
1093 | when reading from a pipe whose other end has been closed, your program |
|
|
1094 | gets send a SIGPIPE, which, by default, aborts your program. For most |
|
|
1095 | programs this is sensible behaviour, for daemons, this is usually |
|
|
1096 | undesirable. |
|
|
1097 | |
|
|
1098 | So when you encounter spurious, unexplained daemon exits, make sure you |
|
|
1099 | ignore SIGPIPE (and maybe make sure you log the exit status of your daemon |
|
|
1100 | somewhere, as that would have given you a big clue). |
|
|
1101 | |
1090 | |
1102 | |
1091 | =head3 Watcher-Specific Functions |
1103 | =head3 Watcher-Specific Functions |
1092 | |
1104 | |
1093 | =over 4 |
1105 | =over 4 |
1094 | |
1106 | |
… | |
… | |
1599 | reader). Inotify will be used to give hints only and should not change the |
1611 | reader). Inotify will be used to give hints only and should not change the |
1600 | semantics of C<ev_stat> watchers, which means that libev sometimes needs |
1612 | semantics of C<ev_stat> watchers, which means that libev sometimes needs |
1601 | to fall back to regular polling again even with inotify, but changes are |
1613 | to fall back to regular polling again even with inotify, but changes are |
1602 | usually detected immediately, and if the file exists there will be no |
1614 | usually detected immediately, and if the file exists there will be no |
1603 | polling. |
1615 | polling. |
|
|
1616 | |
|
|
1617 | =head3 ABI Issues (Largefile Support) |
|
|
1618 | |
|
|
1619 | Libev by default (unless the user overrides this) uses the default |
|
|
1620 | compilation environment, which means that on systems with optionally |
|
|
1621 | disabled large file support, you get the 32 bit version of the stat |
|
|
1622 | structure. When using the library from programs that change the ABI to |
|
|
1623 | use 64 bit file offsets the programs will fail. In that case you have to |
|
|
1624 | compile libev with the same flags to get binary compatibility. This is |
|
|
1625 | obviously the case with any flags that change the ABI, but the problem is |
|
|
1626 | most noticably with ev_stat and largefile support. |
1604 | |
1627 | |
1605 | =head3 Inotify |
1628 | =head3 Inotify |
1606 | |
1629 | |
1607 | When C<inotify (7)> support has been compiled into libev (generally only |
1630 | When C<inotify (7)> support has been compiled into libev (generally only |
1608 | available on Linux) and present at runtime, it will be used to speed up |
1631 | available on Linux) and present at runtime, it will be used to speed up |
… | |
… | |
2509 | io.start (fd, ev::READ); |
2532 | io.start (fd, ev::READ); |
2510 | } |
2533 | } |
2511 | }; |
2534 | }; |
2512 | |
2535 | |
2513 | |
2536 | |
|
|
2537 | =head1 OTHER LANGUAGE BINDINGS |
|
|
2538 | |
|
|
2539 | Libev does not offer other language bindings itself, but bindings for a |
|
|
2540 | numbe rof languages exist in the form of third-party packages. If you know |
|
|
2541 | any interesting language binding in addition to the ones listed here, drop |
|
|
2542 | me a note. |
|
|
2543 | |
|
|
2544 | =over 4 |
|
|
2545 | |
|
|
2546 | =item Perl |
|
|
2547 | |
|
|
2548 | The EV module implements the full libev API and is actually used to test |
|
|
2549 | libev. EV is developed together with libev. Apart from the EV core module, |
|
|
2550 | there are additional modules that implement libev-compatible interfaces |
|
|
2551 | to C<libadns> (C<EV::ADNS>), C<Net::SNMP> (C<Net::SNMP::EV>) and the |
|
|
2552 | C<libglib> event core (C<Glib::EV> and C<EV::Glib>). |
|
|
2553 | |
|
|
2554 | It can be found and installed via CPAN, its homepage is found at |
|
|
2555 | L<http://software.schmorp.de/pkg/EV>. |
|
|
2556 | |
|
|
2557 | =item Ruby |
|
|
2558 | |
|
|
2559 | Tony Arcieri has written a ruby extension that offers access to a subset |
|
|
2560 | of the libev API and adds filehandle abstractions, asynchronous DNS and |
|
|
2561 | more on top of it. It can be found via gem servers. Its homepage is at |
|
|
2562 | L<http://rev.rubyforge.org/>. |
|
|
2563 | |
|
|
2564 | =item D |
|
|
2565 | |
|
|
2566 | Leandro Lucarella has written a D language binding (F<ev.d>) for libev, to |
|
|
2567 | be found at L<http://git.llucax.com.ar/?p=software/ev.d.git;a=summary>. |
|
|
2568 | |
|
|
2569 | =back |
|
|
2570 | |
|
|
2571 | |
2514 | =head1 MACRO MAGIC |
2572 | =head1 MACRO MAGIC |
2515 | |
2573 | |
2516 | Libev can be compiled with a variety of options, the most fundamantal |
2574 | Libev can be compiled with a variety of options, the most fundamantal |
2517 | of which is C<EV_MULTIPLICITY>. This option determines whether (most) |
2575 | of which is C<EV_MULTIPLICITY>. This option determines whether (most) |
2518 | functions and callbacks have an initial C<struct ev_loop *> argument. |
2576 | functions and callbacks have an initial C<struct ev_loop *> argument. |