Last change
on this file since 3531 was 3320, checked in by Bruno Cornec, 10 years ago |
- Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in
the move to 3.0
|
-
Property svn:eol-style
set to
native
|
File size:
862 bytes
|
Line | |
---|
1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * Utility routines.
|
---|
4 | *
|
---|
5 | * Copyright (C) 2007 by Denys Vlasenko <vda.linux@googlemail.com>
|
---|
6 | *
|
---|
7 | * Licensed under GPLv2, see file LICENSE in this source tree.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include "libbb.h"
|
---|
11 |
|
---|
12 | /* Wrapper which restarts poll on EINTR or ENOMEM.
|
---|
13 | * On other errors does perror("poll") and returns.
|
---|
14 | * Warning! May take longer than timeout_ms to return! */
|
---|
15 | int FAST_FUNC safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout)
|
---|
16 | {
|
---|
17 | while (1) {
|
---|
18 | int n = poll(ufds, nfds, timeout);
|
---|
19 | if (n >= 0)
|
---|
20 | return n;
|
---|
21 | /* Make sure we inch towards completion */
|
---|
22 | if (timeout > 0)
|
---|
23 | timeout--;
|
---|
24 | /* E.g. strace causes poll to return this */
|
---|
25 | if (errno == EINTR)
|
---|
26 | continue;
|
---|
27 | /* Kernel is very low on memory. Retry. */
|
---|
28 | /* I doubt many callers would handle this correctly! */
|
---|
29 | if (errno == ENOMEM)
|
---|
30 | continue;
|
---|
31 | bb_perror_msg("poll");
|
---|
32 | return n;
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.