sus

multiple threads doing poll() or select() on a single socket or pipe

泪湿孤枕 提交于 2019-12-18 14:09:46
问题 What do POSIX and other standards say about the situation where multiple threads are doing poll() or select() calls on a single socket or pipe handle at the same time? If any data arrives, does only one of the waiting threads get woken up or do all of the waiting threads get woken up? 回答1: Interesting question ... I read through the current POSIX and did not find a specific answer, i.e., no specification about concurrent invocations. So I'll explain why I think the standard means all will

multiple threads doing poll() or select() on a single socket or pipe

冷暖自知 提交于 2019-12-18 14:09:02
问题 What do POSIX and other standards say about the situation where multiple threads are doing poll() or select() calls on a single socket or pipe handle at the same time? If any data arrives, does only one of the waiting threads get woken up or do all of the waiting threads get woken up? 回答1: Interesting question ... I read through the current POSIX and did not find a specific answer, i.e., no specification about concurrent invocations. So I'll explain why I think the standard means all will

Cross Platform Support for sprintf's Format '-Flag

こ雲淡風輕ζ 提交于 2019-12-04 05:03:00
问题 The Single UNIX Specification Version 2 specifies the sprintf 's format ' -flag behavior as: The integer portion of the result of a decimal conversion ( %i , %d , %u , %f , %g or %G ) will be formatted with thousands' grouping characters [1] I can't find the format ' -flag in the c or the c++ specifications. g++ even warns: ISO C++11 does not support the ' printf flag The flag is not recognized to even warn about in Visual C; printf("%'d", foo) outputs: 'd I'd like to be able to write C

Cross Platform Support for sprintf's Format '-Flag

試著忘記壹切 提交于 2019-12-02 04:13:32
The Single UNIX Specification Version 2 specifies the sprintf 's format ' -flag behavior as: The integer portion of the result of a decimal conversion ( %i , %d , %u , %f , %g or %G ) will be formatted with thousands' grouping characters [ 1 ] I can't find the format ' -flag in the c or the c++ specifications. g++ even warns : ISO C++11 does not support the ' printf flag The flag is not recognized to even warn about in Visual C; printf("%'d", foo) outputs : 'd I'd like to be able to write C-standard compliant code that uses the behavior of the format ' -flag. Thus the answer I'm looking for

Using self-pipe, how can I avoid that the event loop stalls on read()?

大城市里の小女人 提交于 2019-12-01 09:33:09
问题 I am trying to make use of the self-pipe trick to get a portable implementation (across Solaris, MacOSX, Linux, BSDs) of my application. So in addition to the two pipes for stderr and stdout which I am using to fetch the output of the forked child (I use no exec in the child, the child executes the same code as the parent), I have the pipe for signals ( enum {SIG_PIPE, STDOUT_PIPE, STDERR_PIPE, MAX_PIPE} provides the symbolic names). O_NONBLOCK is set on the pipes, prior to calling handle

multiple threads doing poll() or select() on a single socket or pipe

隐身守侯 提交于 2019-11-30 11:03:08
What do POSIX and other standards say about the situation where multiple threads are doing poll() or select() calls on a single socket or pipe handle at the same time? If any data arrives, does only one of the waiting threads get woken up or do all of the waiting threads get woken up? subsub Interesting question ... I read through the current POSIX and did not find a specific answer, i.e., no specification about concurrent invocations. So I'll explain why I think the standard means all will wake up. The relevant part of the text for select / pselect is: Upon successful completion, the pselect(