mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-23 11:24:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d07cc616e | ||
|
|
9db9daec07 | ||
|
|
af1a484c46 | ||
|
|
1e6395a85a | ||
|
|
5c8a258c3f | ||
|
|
e79d25bb42 | ||
|
|
6dccc05e0d | ||
|
|
de95022f44 | ||
|
|
041240a93d | ||
|
|
837d8c1e16 | ||
|
|
a334d230a1 | ||
|
|
2a709f739d | ||
|
|
d4096c8c0c | ||
|
|
38858488b9 | ||
|
|
90048e5996 | ||
|
|
fd89af6ca1 | ||
|
|
399d75a05c | ||
|
|
6439a34670 |
No files matched your search
@@ -87,6 +87,11 @@ int uev_signal_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int sign
|
||||
int uev_signal_set (uev_t *w, int signo); /* Change signal to wait for */
|
||||
int uev_signal_start(uev_t *w); /* Restart a stopped signal watcher */
|
||||
int uev_signal_stop (uev_t *w); /* Stop signal watcher */
|
||||
|
||||
/* Generic event watcher, post events for later processing, or from forked child */
|
||||
int uev_event_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg);
|
||||
int uev_event_post (uev_t *w);
|
||||
int uev_event_stop (uev_t *w);
|
||||
```
|
||||
|
||||
|
||||
@@ -309,16 +314,16 @@ static void joystick_cb(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd;
|
||||
uev_t watcher;
|
||||
uev_ctx_t ctx;
|
||||
uev_t js;
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/input/js0", O_RDONLY, O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
errx(errno, "Cannot find a joystick attached.");
|
||||
|
||||
uev_init(&ctx);
|
||||
uev_io_init(&ctx, &watcher, joystick_cb, NULL, fd, UEV_READ);
|
||||
uev_io_init(&ctx, &js, joystick_cb, NULL, fd, UEV_READ);
|
||||
|
||||
puts("Starting, press Ctrl-C to exit.");
|
||||
|
||||
|
||||
+17
-1
@@ -3,6 +3,21 @@ Change Log
|
||||
|
||||
All notable changes to the project are documented in this file.
|
||||
|
||||
[v2.3.1][] - 2020-02-22
|
||||
-----------------------
|
||||
|
||||
### Fixes
|
||||
|
||||
- Debian packaging fixes only.
|
||||
|
||||
|
||||
[v2.3.0][] - 2019-04-06
|
||||
-----------------------
|
||||
|
||||
### Changes
|
||||
|
||||
- Support for Linux eventfd, `uev_event_*()` see [API.md][] for details
|
||||
|
||||
|
||||
[v2.2.0][] - 2018-10-04
|
||||
-----------------------
|
||||
@@ -384,7 +399,8 @@ v0.0.1 - 2012-03-17
|
||||
Lua users mailing list.
|
||||
|
||||
|
||||
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v2.2.0...HEAD
|
||||
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v2.3.0...HEAD
|
||||
[v2.3.0]: https://github.com/troglobit/libuev/compare/v2.2.0...v2.3.0
|
||||
[v2.2.0]: https://github.com/troglobit/libuev/compare/v2.1.3...v2.2.0
|
||||
[v2.1.3]: https://github.com/troglobit/libuev/compare/v2.1.2...v2.1.3
|
||||
[v2.1.2]: https://github.com/troglobit/libuev/compare/v2.1.1...v2.1.2
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
Maintenance and Release Checklist
|
||||
=================================
|
||||
|
||||
Maintenance
|
||||
-----------
|
||||
|
||||
* Encourage contributors to write tests, in particular for new features
|
||||
* Run tests regularly, use Travis-CI to do this automatically
|
||||
* Leverage GitHub issues for milestone planning
|
||||
* Reference issues from GitHub pull requests to alert issue subscribers
|
||||
* Bump library ABI version just before release!
|
||||
|
||||
|
||||
Release Checklist
|
||||
-----------------
|
||||
|
||||
* Update ChangeLog, follow http://keepachangelog.com/ loosely
|
||||
- Inform users in a plain language of changes and bug fixes
|
||||
- Do *not* copy-paste GIT commit logs!
|
||||
- Order entries according to importance, most relevant first
|
||||
* Run unit tests: `make check`
|
||||
* Make at least one `-rcN` release and test it in an actual real project
|
||||
* **REMEMBER:** bump ABI version according to below rules
|
||||
* Tag
|
||||
* Push last commit(s) *and* tags to GitHub
|
||||
* Make release
|
||||
|
||||
make distclean
|
||||
./autogen.sh
|
||||
./configure
|
||||
make release
|
||||
|
||||
* Create new release in GitHub releases page
|
||||
* Copy and paste ChangeLog entry, check any stale links!
|
||||
* Upload release tarball and MD5 files
|
||||
|
||||
|
||||
Library Versioning
|
||||
------------------
|
||||
|
||||
libuEv relies on GNU Libtool for building the library. For users of the
|
||||
library it is important to maintain a clear ABI versioning scheme. This
|
||||
is not the same as the libuEv version, but rather its "compatibility
|
||||
level".
|
||||
|
||||
The libuEv ABI version is specified in `src/Makefile.am`:
|
||||
|
||||
libuev_la_LDFLAGS = -version-info 0:0:0
|
||||
\ \ `-- age
|
||||
\ `--- revision
|
||||
`---- current
|
||||
|
||||
It must be updated according to the [GNU Libtool recommendations][1]:
|
||||
|
||||
1. Start with version information of `0:0:0` for each libtool library.
|
||||
2. Update the version information only immediately before a public
|
||||
release of your software. More frequent updates are unnecessary, and
|
||||
only guarantee that the current interface number gets larger faster.
|
||||
3. If the library *source code has changed at all* since the last update,
|
||||
then increment revision (`c:r:a` becomes `c:r+1:a`).
|
||||
4. If any *interfaces have been added, removed, or changed* since the
|
||||
last update, increment current, and set revision to 0.
|
||||
5. If any *interfaces have been added* since the last public release,
|
||||
then increment age.
|
||||
6. If any *interfaces have been removed or changed* since the last
|
||||
public release, then set age to 0.
|
||||
|
||||
The libtool ABI versioning logic is very confusing but works if you just
|
||||
disable your brain and follow the rules, one by one.
|
||||
|
||||
**Example #1:** a new function has been added, none of the existing ones
|
||||
have changed. The initial version is 1:0:0, we follow the rules above to
|
||||
the letter: increase revision, increase current and set revision to zero,
|
||||
and finally increase age. This, rather confusingly, gives us 2:0:1 which
|
||||
libtool then translates to `libuev.so.1.1.0`.
|
||||
|
||||
**Example #2:** some existing functions are changed, they now return an
|
||||
`int` instead of `void`. The initial version is 0:0:0, and we follow the
|
||||
rules again: increment revision, increment current and set revision to
|
||||
zero, set age to zero. This gives us 1:0:0, which is then translated to
|
||||
`libuev.so.1.0.0`.
|
||||
|
||||
|
||||
### Note
|
||||
|
||||
Usually, non-developers have no interest in running development versions
|
||||
(releases are frequent enough), and developers are expected to know how
|
||||
to juggle versions. In such an ideal world, it is good enough to bump
|
||||
the library version just prior to a release, point 2.
|
||||
|
||||
However, if releases are few and far between, distributors may start to
|
||||
use snapshots. When a distributor uses a snapshot, the distributor has
|
||||
to handle the library version manually. Things can get ugly when the
|
||||
distributor has released an intermediate version with a bumped library
|
||||
version, and when the official release is bumped to that version, the
|
||||
distributor will then have to bump the library version for the official
|
||||
release, and it can be confusing if someone reports bugs on versions
|
||||
that you didn't even know existed.
|
||||
|
||||
The problem with bumping the version with every change is that if your
|
||||
interface is not finished, the version number might run away, and it
|
||||
looks pretty bad if a library is at version 262. It kind of tells the
|
||||
user that the library interface is volatile, which is not good for
|
||||
business.
|
||||
|
||||
[1]: https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
libuEv | Simple event loop for Linux
|
||||
====================================
|
||||
µEv | Simple event loop for Linux
|
||||
==================================
|
||||
[![Travis Status][]][Travis] [![Coverity Status][]][Coverity Scan]
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ libuEv | Simple event loop for Linux
|
||||
Introduction
|
||||
------------
|
||||
|
||||
[libuEv][] is a simple event loop in the style of the more established
|
||||
[libevent][1], [libev][2] and the venerable [Xt(3)][3] event loop. The
|
||||
*u* (micro) in the name refers to both the small feature set and the
|
||||
small size overhead impact of the library.
|
||||
[libuEv][] is a small event loop that wraps the Linux `epoll()` family
|
||||
of APIs. It is similar to the more established [libevent][], [libev][]
|
||||
and the venerable [Xt(3)][] event loop. The *µ* in the name refers to
|
||||
both its limited feature set and the size impact of the library.
|
||||
|
||||
Failure mode changes introduced in v2.0 may affect users of v1.x, See
|
||||
the [ChangeLog][] for the full details.
|
||||
@@ -34,34 +34,35 @@ The [API documentation](API.md) is available as a separate document.
|
||||
Example
|
||||
-------
|
||||
|
||||
Notice below how watcher `UEV_ERROR` conditions must be handled by each
|
||||
Notice how watcher conditions like `UEV_ERROR` must be handled by each
|
||||
callback. I/O watchers must also check for `UEV_HUP`. Both errors are
|
||||
usually fatal, libuEv makes sure to stop each watcher before a callback
|
||||
runs, leaving it up to the callback to take appropriate action.
|
||||
|
||||
```C
|
||||
/* Set up a timer watcher to call cb() every other second */
|
||||
#include <stdio.h>
|
||||
#include <uev/uev.h>
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
if (UEV_ERROR == events) {
|
||||
puts("Problem with timer, attempting to restart.");
|
||||
uev_timer_start(w);
|
||||
}
|
||||
puts("Every other second");
|
||||
if (UEV_ERROR == events) {
|
||||
puts("Problem with timer, attempting to restart.");
|
||||
uev_timer_start(w);
|
||||
}
|
||||
|
||||
puts("Every other second");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_t timer;
|
||||
uev_ctx_t ctx;
|
||||
uev_ctx_t ctx;
|
||||
uev_t timer;
|
||||
|
||||
uev_init(&ctx);
|
||||
/* Set up a timer watcher to call cb() every other second */
|
||||
uev_timer_init(&ctx, &timer, cb, NULL, 2 * 1000, 2 * 1000);
|
||||
uev_init(&ctx);
|
||||
uev_timer_init(&ctx, &timer, cb, NULL, 2 * 1000, 2 * 1000);
|
||||
|
||||
return uev_run(&ctx, 0);
|
||||
return uev_run(&ctx, 0);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -82,36 +83,40 @@ sudo make install-strip
|
||||
sudo ldconfig
|
||||
```
|
||||
|
||||
The resulting .so file is ~14 kiB.
|
||||
The resulting .so library is ~23 kiB.
|
||||
|
||||
To build from GIT sources; clone the repository and run the `autogen.sh`
|
||||
script. This requires GNU `automake`, `autoconf` amd `libtool` to be
|
||||
installed on your system. (If you build from a released tarball you do
|
||||
not need them.)
|
||||
|
||||
|
||||
Origin & References
|
||||
-------------------
|
||||
|
||||
[libuEv][] originates from [LibUEvent][8] by [Flemming Madsen][], but
|
||||
with a rewritten and much cleaner API. It is now more similar to the
|
||||
famous [libev][2] by [Mark Lehmann][]. Another library inspiring this
|
||||
project is [picoev][9] by [Oku Kazuho][].
|
||||
[libuEv][] is developed and maintained by [Joachim Nilsson][] on GitHub.
|
||||
It is primarily built for and developed on GNU/Linux systems, patches to
|
||||
support the BSD [kqueue][] interface are most welcome.
|
||||
|
||||
[libuEv][] is developed and maintained by [Joachim Nilsson][]. It is
|
||||
built for and developed on GNU/Linux systems, patches to support *BSD
|
||||
and its [kqueue][] interface are most welcome.
|
||||
Originally based on [LibUEvent][] by [Flemming Madsen][], uEv has since
|
||||
evolved to support all of the Linux `epoll()` family APIs. It is now
|
||||
more similar to the excellent [libev][] by [Mark Lehmann][], with some
|
||||
inspiration also from [picoev][] by [Oku Kazuho][].
|
||||
|
||||
|
||||
[1]: http://libevent.org
|
||||
[2]: http://software.schmorp.de/pkg/libev.html
|
||||
[3]: http://unix.com/man-page/All/3x/XtDispatchEvent
|
||||
[8]: http://code.google.com/p/libuevent/
|
||||
[9]: https://github.com/kazuho/picoev
|
||||
[ChangeLog]: https://github.com/troglobit/libuev/blob/master/ChangeLog.md
|
||||
[Travis]: https://travis-ci.org/troglobit/libuev
|
||||
[Travis Status]: https://travis-ci.org/troglobit/libuev.png?branch=master
|
||||
[Coverity Scan]: https://scan.coverity.com/projects/3846
|
||||
[Coverity Status]: https://scan.coverity.com/projects/3846/badge.svg
|
||||
[libevent]: https://libevent.org
|
||||
[Xt(3)]: https://unix.com/man-page/All/3x/XtDispatchEvent
|
||||
[LibUEvent]: https://code.google.com/p/libuevent/
|
||||
[picoev]: https://github.com/kazuho/picoev
|
||||
[libev]: http://software.schmorp.de/pkg/libev.html
|
||||
[LibuEv]: https://github.com/troglobit/libuev
|
||||
[kqueue]: https://github.com/mheily/libkqueue
|
||||
[Oku Kazuho]: https://github.com/kazuho
|
||||
[Mark Lehmann]: http://software.schmorp.de
|
||||
[Joachim Nilsson]: http://troglobit.com
|
||||
[Flemming Madsen]: http://www.madsensoft.dk
|
||||
[Dave Zarzycki, Apple]: http://www.youtube.com/watch?v=cD_s6Fjdri8
|
||||
+3
-1
@@ -1,4 +1,5 @@
|
||||
AC_INIT(libuev, 2.2.0, https://github.com/troglobit/libuev/issues)
|
||||
AC_INIT(libuev, 2.3.1, https://github.com/troglobit/libuev/issues)
|
||||
AC_CONFIG_AUX_DIR(aux)
|
||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
@@ -8,6 +9,7 @@ AC_CONFIG_FILES([Makefile src/libuev.pc src/Makefile examples/Makefile tests/Mak
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
LT_INIT
|
||||
|
||||
|
||||
Vendored
+3
-3
@@ -8,7 +8,7 @@ based operating system, e.g. Debian, Ubuntu, Linux Mint, etc.
|
||||
|
||||
Recommended reading is the upstream README and API docs.
|
||||
|
||||
less /usr/share/doc/libuev-dev/README.md
|
||||
zless /usr/share/doc/libuev-dev/API.md.gz
|
||||
less /usr/share/doc/libuev-dev/README.md
|
||||
less /usr/share/doc/libuev-dev/API.md
|
||||
|
||||
-- Joachim Nilsson <troglobit@gmail.com> Thu, 21 Sep 18:10, 2017
|
||||
-- Joachim Nilsson <troglobit@gmail.com> Sat, 6 Apr 13:18, 2019
|
||||
Vendored
+13
@@ -1,3 +1,16 @@
|
||||
libuev (2.3.1) stable; urgency=high
|
||||
|
||||
* Step library name to match SONAME, found by lintian
|
||||
* Update Build-Depends to debhelper >= 10, drop other deps
|
||||
|
||||
-- Joachim Nilsson <troglobit@gmail.com> Sat, 22 Feb 2020 15:50:06 +0100
|
||||
|
||||
libuev (2.3.0) unstable; urgency=medium
|
||||
|
||||
* Support for Linux eventfd, uev_event_*(), see API.md for details.
|
||||
|
||||
-- Joachim Nilsson <troglobit@gmail.com> Thu, 06 Apr 2019 13:09:31 +0200
|
||||
|
||||
libuev (2.2.0) unstable; urgency=medium
|
||||
|
||||
* Replaced BSD queue.h with own linked list implementation. This means
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
9
|
||||
10
|
||||
Vendored
+23
-22
@@ -1,39 +1,40 @@
|
||||
Source: libuev
|
||||
Section: libs
|
||||
Priority: optional
|
||||
Maintainer: Joachim Nilsson <troglobit@gmail.com>
|
||||
Build-Depends: dpkg-dev (>= 1.14.9), debhelper (>= 9), dh-autoreconf
|
||||
Standards-Version: 3.9.6
|
||||
Section: libs
|
||||
Build-Depends: debhelper (>= 10)
|
||||
Standards-Version: 4.3.0
|
||||
Homepage: https://github.com/troglobit/libuev/
|
||||
Vcs-Git: https://github.com/troglobit/libuev.git
|
||||
Vcs-Browser: https://github.com/troglobit/libuev/
|
||||
Vcs-Git: https://github.com/troglobit/libuev.git
|
||||
|
||||
Package: libuev-dev
|
||||
Priority: extra
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}, libuev (= ${binary:Version})
|
||||
Depends: ${misc:Depends}, libuev2 (= ${binary:Version})
|
||||
Description: static library, header files, and docs for libuev
|
||||
Static library, header files, and documentation for libuev.
|
||||
Static library, header files, and documentation for libuEv
|
||||
.
|
||||
libuEv is a simple event loop in the style of the more established
|
||||
libevent, libev and the venerable Xt(3) event loop. The u (micro) in the
|
||||
name refers to both the small feature set and the small size overhead
|
||||
impact of the library.
|
||||
libuEv is a small event loop that wraps the Linux epoll() family of APIs.
|
||||
It is similar to the more established libevent, libev and the venerable
|
||||
Xt(3) event loop. The u (micro) in the name refers to both its limited
|
||||
feature set and the small size impact of the library.
|
||||
.
|
||||
Experienced developers may appreciate that libuEv is built on top of
|
||||
modern Linux APIs: epoll, timerfd and signalfd. Note however, a certain
|
||||
amount of care is needed when dealing with APIs that employ signalfd.
|
||||
Experienced developers may appreciate libuEv is built on top of modern
|
||||
Linux APIs like epoll, eventfd, timerf, and signalfd.
|
||||
|
||||
Package: libuev
|
||||
Package: libuev2
|
||||
Replaces: libuev
|
||||
Conflicts: libuev
|
||||
Provides: libuev
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}, ${shlibs:Depends}
|
||||
Description: Lightweight event loop library
|
||||
libuEv is a simple event loop in the style of the more established
|
||||
libevent, libev and the venerable Xt(3) event loop. The u (micro) in the
|
||||
name refers to both the small feature set and the small size overhead
|
||||
impact of the library.
|
||||
Description: Lightweight event loop library for Linux
|
||||
libuEv is a small event loop that wraps the Linux epoll() family of APIs.
|
||||
It is similar to the more established libevent, libev and the venerable
|
||||
Xt(3) event loop. The u (micro) in the name refers to both its limited
|
||||
feature set and the small size impact of the library.
|
||||
.
|
||||
Experienced developers may appreciate that libuEv is built on top of
|
||||
modern Linux APIs: epoll, timerfd and signalfd. Note however, a certain
|
||||
amount of care is needed when dealing with APIs that employ signalfd.
|
||||
Experienced developers may appreciate libuEv is built on top of modern
|
||||
Linux APIs like epoll, eventfd, timerfd, and signalfd.
|
||||
Vendored
+28
-19
@@ -1,26 +1,35 @@
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: libuEv
|
||||
Upstream-Contact: troglobit@gmail.com
|
||||
Source: https.//github.com/troglobit/libuev/
|
||||
Comment: Debianized by upstream on Mon, Nov 28 2016 23:23:17 +0100
|
||||
|
||||
Files: *
|
||||
Copyright: 2013-2017 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2012 Flemming Madsen <flemming.madsen@madsensoft.dk>
|
||||
2013-2019 Joachim Nilsson <troglobit@gmail.com>
|
||||
License: MIT
|
||||
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Files: debian/*
|
||||
Copyright: 2016-2019 Joachim Nilsson <troglobit@gmail.com>
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
License: MIT
|
||||
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
usr/lib
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
usr/lib
|
||||
usr/share
|
||||
File renamed without changes.
Vendored
+8
-1
@@ -1,10 +1,17 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
|
||||
%:
|
||||
dh $@ --with autoreconf
|
||||
|
||||
override_dh_compress:
|
||||
dh_compress -A -X.md
|
||||
|
||||
override_dh_installchangelogs:
|
||||
dh_installchangelogs ChangeLog.md
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install
|
||||
find debian -name LICENSE -delete
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/* Simple example of how to use libuEv with Linux joystick API
|
||||
*
|
||||
* Copyright (c) 2014-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2014-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -74,16 +74,16 @@ static void joystick_cb(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd;
|
||||
uev_t js1_watcher;
|
||||
uev_ctx_t ctx;
|
||||
uev_t js1;
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/input/js0", O_RDONLY, O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
errx(errno, "Cannot find a joystick attached.");
|
||||
|
||||
uev_init(&ctx);
|
||||
uev_io_init(&ctx, &js1_watcher, joystick_cb, NULL, fd, UEV_READ);
|
||||
uev_io_init(&ctx, &js1, joystick_cb, NULL, fd, UEV_READ);
|
||||
|
||||
puts("Starting, press Ctrl-C to exit.");
|
||||
|
||||
|
||||
+2
-2
@@ -47,9 +47,9 @@ void process_stdin(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
uev_t watcher;
|
||||
uev_ctx_t ctx;
|
||||
uev_t watcher;
|
||||
int ret;
|
||||
|
||||
uev_init(&ctx);
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
lib_LTLIBRARIES = libuev.la
|
||||
libuev_la_SOURCES = uev.c uev.h private.h io.c timer.c signal.c cron.c
|
||||
libuev_la_SOURCES = uev.c uev.h private.h io.c timer.c signal.c cron.c event.c
|
||||
libuev_la_CPPFLAGS = -D_GNU_SOURCE -D_TIME_BITS=64
|
||||
libuev_la_CFLAGS = -W -Wall -Wextra -std=gnu11
|
||||
libuev_la_LDFLAGS = $(AM_LDFLAGS) -version-info 3:0:1
|
||||
libuev_la_LDFLAGS = $(AM_LDFLAGS) -version-info 4:0:2
|
||||
|
||||
noinst_PROGRAMS = bench
|
||||
bench_CPPFLAGS = -D_GNU_SOURCE
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <unistd.h> /* close(), read() */
|
||||
|
||||
#include "uev.h"
|
||||
|
||||
|
||||
/**
|
||||
* Create a generic event watcher
|
||||
* @param ctx A valid libuEv context
|
||||
* @param w Pointer to an uev_t watcher
|
||||
* @param cb Callback when an event is posted
|
||||
* @param arg Optional callback argument
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_event_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!w || !ctx) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
w->fd = -1;
|
||||
|
||||
fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
return _uev_watcher_init(ctx, w, UEV_EVENT_TYPE, cb, arg, fd, UEV_READ)
|
||||
|| _uev_watcher_start(w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a generic event
|
||||
* @param w Watcher to post to
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_event_post(uev_t *w)
|
||||
{
|
||||
uint64_t val = 1;
|
||||
|
||||
if (!w || -1 == w->fd) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (write(w->fd, &val, sizeof(val)) != sizeof(val))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a generic event watcher
|
||||
* @param w Watcher to stop
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_event_stop(uev_t *w)
|
||||
{
|
||||
if (!_uev_watcher_active(w))
|
||||
return 0;
|
||||
|
||||
if (_uev_watcher_stop(w))
|
||||
return -1;
|
||||
|
||||
close(w->fd);
|
||||
w->fd = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Private methods and data types, do not use directly!
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -66,6 +66,7 @@ typedef enum {
|
||||
UEV_SIGNAL_TYPE,
|
||||
UEV_TIMER_TYPE,
|
||||
UEV_CRON_TYPE,
|
||||
UEV_EVENT_TYPE,
|
||||
} uev_type_t;
|
||||
|
||||
/* Event mask, used internally only. */
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,7 +34,7 @@
|
||||
* Create a signal watcher
|
||||
* @param ctx A valid libuEv context
|
||||
* @param w Pointer to an uev_t watcher
|
||||
* @param cb Timer callback
|
||||
* @param cb Signal callback
|
||||
* @param arg Optional callback argument
|
||||
* @param signo Signal to watch for
|
||||
*
|
||||
@@ -42,8 +42,8 @@
|
||||
*/
|
||||
int uev_signal_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo)
|
||||
{
|
||||
int fd;
|
||||
sigset_t mask;
|
||||
int fd;
|
||||
|
||||
if (!w || !ctx) {
|
||||
errno = EINVAL;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2017 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -245,17 +245,21 @@ int uev_exit(uev_ctx_t *ctx)
|
||||
continue;
|
||||
|
||||
switch (w->type) {
|
||||
case UEV_CRON_TYPE:
|
||||
case UEV_TIMER_TYPE:
|
||||
uev_timer_stop(w);
|
||||
case UEV_IO_TYPE:
|
||||
uev_io_stop(w);
|
||||
break;
|
||||
|
||||
case UEV_SIGNAL_TYPE:
|
||||
uev_signal_stop(w);
|
||||
break;
|
||||
|
||||
case UEV_IO_TYPE:
|
||||
uev_io_stop(w);
|
||||
case UEV_TIMER_TYPE:
|
||||
case UEV_CRON_TYPE:
|
||||
uev_timer_stop(w);
|
||||
break;
|
||||
|
||||
case UEV_EVENT_TYPE:
|
||||
uev_event_stop(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -285,8 +289,8 @@ int uev_exit(uev_ctx_t *ctx)
|
||||
*/
|
||||
int uev_run(uev_ctx_t *ctx, int flags)
|
||||
{
|
||||
int timeout = -1;
|
||||
uev_t *w;
|
||||
int timeout = -1;
|
||||
|
||||
if (!ctx || ctx->fd < 0) {
|
||||
errno = EINVAL;
|
||||
@@ -308,8 +312,8 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
}
|
||||
|
||||
while (ctx->running && ctx->watchers) {
|
||||
int i, nfds, rerun = 0;
|
||||
struct epoll_event ee[UEV_MAX_EVENTS];
|
||||
int i, nfds, rerun = 0;
|
||||
|
||||
/* Handle special case: `application < file.txt` */
|
||||
if (ctx->workaround) {
|
||||
@@ -345,9 +349,9 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
}
|
||||
|
||||
for (i = 0; ctx->running && i < nfds; i++) {
|
||||
uint64_t exp;
|
||||
uint32_t events;
|
||||
struct signalfd_siginfo fdsi;
|
||||
uint32_t events;
|
||||
uint64_t exp;
|
||||
ssize_t sz = sizeof(fdsi);
|
||||
|
||||
w = (uev_t *)ee[i].data.ptr;
|
||||
@@ -396,6 +400,11 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
if (!w->u.c.when)
|
||||
uev_timer_stop(w);
|
||||
break;
|
||||
|
||||
case UEV_EVENT_TYPE:
|
||||
if (read(w->fd, &exp, sizeof(exp)) != sizeof(exp))
|
||||
events = UEV_HUP;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -47,9 +47,10 @@
|
||||
|
||||
/* Macros */
|
||||
#define uev_io_active(w) _uev_watcher_active(w)
|
||||
#define uev_signal_active(w) _uev_watcher_active(w)
|
||||
#define uev_timer_active(w) _uev_watcher_active(w)
|
||||
#define uev_cron_active(w) _uev_watcher_active(w)
|
||||
#define uev_signal_active(w) _uev_watcher_active(w)
|
||||
#define uev_event_active(w) _uev_watcher_active(w)
|
||||
|
||||
/* Event watcher */
|
||||
typedef struct uev {
|
||||
@@ -100,6 +101,10 @@ int uev_signal_set (uev_t *w, int signo);
|
||||
int uev_signal_start (uev_t *w);
|
||||
int uev_signal_stop (uev_t *w);
|
||||
|
||||
int uev_event_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg);
|
||||
int uev_event_post (uev_t *w);
|
||||
int uev_event_stop (uev_t *w);
|
||||
|
||||
#endif /* LIBUEV_UEV_H_ */
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,3 +6,4 @@ complete
|
||||
cronrun
|
||||
signal
|
||||
timer
|
||||
event
|
||||
@@ -8,6 +8,7 @@ TESTS += complete
|
||||
TESTS += cronrun
|
||||
TESTS += signal
|
||||
TESTS += timer
|
||||
TESTS += event
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
|
||||
+1
-1
@@ -38,8 +38,8 @@ static void cb(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
struct timeval tomorrow;
|
||||
uev_ctx_t ctx;
|
||||
|
||||
gettimeofday(&tomorrow, NULL);
|
||||
tomorrow.tv_sec += 24 * 60 * 60;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Test libuEv event library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2013-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/* Test cron API in libuEv event library
|
||||
*
|
||||
* Copyright (c) 2016 Joachim Nilsson <troglobit()gmail!com>
|
||||
* Copyright (c) 2016-2019 Joachim Nilsson <troglobit()gmail!com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,8 +33,8 @@ struct timeval tv;
|
||||
|
||||
static void cron_job(uev_t *w, void *arg, int events)
|
||||
{
|
||||
static int laps = 3;
|
||||
struct timeval now;
|
||||
static int laps = 3;
|
||||
|
||||
if (UEV_ERROR == events)
|
||||
fprintf(stderr, "cron watcher failed, ignoring ...\n");
|
||||
@@ -54,10 +54,10 @@ static void cron_job(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc;
|
||||
uev_t cron_watcher;
|
||||
uev_ctx_t ctx;
|
||||
time_t when, interval;
|
||||
uev_t cron;
|
||||
int rc;
|
||||
|
||||
uev_init(&ctx);
|
||||
|
||||
@@ -68,7 +68,7 @@ int main(void)
|
||||
printf("Expected cron %s", ctime(&when));
|
||||
|
||||
interval = INTERVAL;
|
||||
uev_cron_init(&ctx, &cron_watcher, cron_job, NULL, when, interval);
|
||||
uev_cron_init(&ctx, &cron, cron_job, NULL, when, interval);
|
||||
|
||||
rc = uev_run(&ctx, 0);
|
||||
fail_unless(result == 0);
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/* Verifies eventfd support
|
||||
*
|
||||
* Copyright (c) 2018-2019 Joachim Nilsson <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#define LAPS 10
|
||||
pid_t pid;
|
||||
|
||||
static void cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
static int num = LAPS;
|
||||
|
||||
num--;
|
||||
// printf("Got event %d ...\n", LAPS - num);
|
||||
if (num == 0) {
|
||||
waitpid(pid, NULL, 0);
|
||||
uev_exit(w->ctx);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_ctx_t ctx;
|
||||
uev_t ev;
|
||||
int i;
|
||||
|
||||
/* Initialize libuEv */
|
||||
uev_init(&ctx);
|
||||
|
||||
/* Setup callbacks */
|
||||
uev_event_init(&ctx, &ev, cb, NULL);
|
||||
|
||||
pid = fork();
|
||||
if (-1 == pid)
|
||||
err(1, "fork");
|
||||
|
||||
/* Start event loop */
|
||||
if (pid > 0)
|
||||
return uev_run(&ctx, 0);
|
||||
|
||||
for (i = 0; i < LAPS; i++) {
|
||||
uev_event_post(&ev);
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/* Multiple signals, segfault and fork() to test sub-processes.
|
||||
*
|
||||
* Copyright (c) 2015 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2015-2019 Joachim Nilsson <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -81,8 +81,8 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
|
||||
|
||||
static void work_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
int status = 0;
|
||||
pid_t pid;
|
||||
pid_t pid;
|
||||
int status = 0;
|
||||
|
||||
pid = fork();
|
||||
if (-1 == pid)
|
||||
@@ -113,8 +113,8 @@ static void exit_cb(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uev_t sigsegv_watcher, sigchld_watcher, timeout_watcher, deadline_watcher;
|
||||
uev_ctx_t ctx;
|
||||
uev_t sigsegv_watcher, sigchld_watcher, timeout_watcher, deadline_watcher;
|
||||
|
||||
/* Initialize libuEv */
|
||||
uev_init(&ctx);
|
||||
|
||||
+2
-2
@@ -23,9 +23,9 @@ static void cb(uev_t *w, void *arg, int events)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc;
|
||||
uev_t w;
|
||||
uev_ctx_t ctx;
|
||||
uev_t w;
|
||||
int rc;
|
||||
|
||||
uev_init(&ctx);
|
||||
uev_timer_init(&ctx, &w, cb, NULL, TIMEOUT * 1000, 0);
|
||||
|
||||
Reference in new issue
Block a user