posix

What is select supposed to do if you close a monitored fd?

我的梦境 提交于 2020-01-01 17:06:30
问题 I can test this to find the behavior but that's not the point. In my answer to another question, a commenter recommended closing a monitored fd from another thread to wake up select . Another commenter couldn't find a reference to this behavior in the standard, and I can't find one either. Can someone provide a pointer to the standard on this behavior? 回答1: From the description of select in "The Open Group Base Specifications Issue 7": A descriptor shall be considered ready for reading when a

How to loop through only active file descriptors from fd_set result from select()?

那年仲夏 提交于 2020-01-01 10:03:53
问题 So in my current server implementation, it is currently something like this: void loop(){ // step 1: clear set fd_set readfds; while(true){ // step 1: FD_ZERO(readfds); // step 2: loop_through_sockets_and_add_active_sockets_to(theset); // step 3: switch(select(FD_SETSIZE, &readfds, 0, 0, &tv)) { case SOCKET_ERROR: patia->receiveEvent(Error, net::getError()); return; case 0: return; } // step 4: loop through sockets and check, using FD_ISSET, which read fd's have incoming data. } } Now, not

posix_fadvise(WILLNEED) makes IO slower?

孤街浪徒 提交于 2020-01-01 09:16:37
问题 On a CentOS 5.5 machine running Linux kernel version 2.6.18-194.26.1.el5, I noticed that posix_fadvise(WILLNEED) makes reading 60K files much slower than just regular IO by almost 200%. It seems that the actual fadvise call is synchronous, and it also delays scheduling other threads in the application that use the data being read from the files. Is it possible that the kernel is busy with fetching data from the disks due to the fadvise call, and ends up delaying other scheduled task? It seems

Why does Perl's POSIX::strftime %F specifier not work on Windows?

ぐ巨炮叔叔 提交于 2020-01-01 08:43:02
问题 I'm the author of the Mac::PropertyList module which parses the Apple property list format. I've designed this to work across platforms, but I'm having trouble with POSIX's strftime function which I use to create the date fields in the format that Apple specifies. use POSIX; print 'Epoch is: ' . POSIX::strftime( "%FT%H:%M:%SZ\n", gmtime(978307200) ); On unix-like platforms, including darwin, this call produces the right sort of date: 2013-09-23T12:34:56Z On Windows, it produces: T12:34:56Z

Why does Perl's POSIX::strftime %F specifier not work on Windows?

耗尽温柔 提交于 2020-01-01 08:41:51
问题 I'm the author of the Mac::PropertyList module which parses the Apple property list format. I've designed this to work across platforms, but I'm having trouble with POSIX's strftime function which I use to create the date fields in the format that Apple specifies. use POSIX; print 'Epoch is: ' . POSIX::strftime( "%FT%H:%M:%SZ\n", gmtime(978307200) ); On unix-like platforms, including darwin, this call produces the right sort of date: 2013-09-23T12:34:56Z On Windows, it produces: T12:34:56Z

MAP_ANONYMOUS with C99 standard

孤街醉人 提交于 2020-01-01 07:33:08
问题 I have an application that uses the mmap system call, I was having an issue getting it to compile for hours looking as to why I was getting MAP_ANON and MAP_ANONYMOUS were undeclared, I had a smaller section of code that I used and I saw I could compile it just fine so I tried just a basic compile and that worked, I saw that it fails when you add -std=c99. Is there a specific reason that MAP_ANON and MAP_ANONYMOUS are not valid in the C99 standard? I know that they aren't defined by POSIX but

Why child process returns exit status = 32512 in unix?

余生长醉 提交于 2020-01-01 04:19:09
问题 In my program I'm executing given command and getting result (log, and exit status). Also my program have to support shell specific commands (i.e. commands which contains shell specific characters ~(tild),|(pipe),*). But when I try to run sh -c ls | wc in my home directory via my program it failed and its exit status was 32512, also in stderr stream "sh: ls | wc: command not found" was printed. But the interesting thing is that the command sh -c ls | wc works correct if I run it in shell.

Why child process returns exit status = 32512 in unix?

时光怂恿深爱的人放手 提交于 2020-01-01 04:19:05
问题 In my program I'm executing given command and getting result (log, and exit status). Also my program have to support shell specific commands (i.e. commands which contains shell specific characters ~(tild),|(pipe),*). But when I try to run sh -c ls | wc in my home directory via my program it failed and its exit status was 32512, also in stderr stream "sh: ls | wc: command not found" was printed. But the interesting thing is that the command sh -c ls | wc works correct if I run it in shell.

NSPOSIXErrorDomain Code=12 “Cannot allocate memory” in 3G network

跟風遠走 提交于 2020-01-01 00:12:11
问题 I'm trying to send a file on FTP server in my iPhone application. Everything seems to be okay in WiFi and GSM:EDGE network, but in 3G network an error appears (not always, but very often): Error Domain=NSPOSIXErrorDomain Code=12 "The operation couldn’t be completed. Cannot allocate memory" Below the code where the error appears: - (void)stream:(NSStream*)aStream handleEvent:(NSStreamEvent)eventCode { switch( eventCode ) { case NSStreamEventHasSpaceAvailable: { if( _readDataOffset ==

How are POSIX cancellation points supposed to behave?

此生再无相见时 提交于 2019-12-31 21:53:08
问题 I've been looking at glibc/nptl's implementation of cancellation points, and comparing it to POSIX, and unless I'm mistaken it's completely wrong. The basic model used is: int oldtype = LIBC_ASYNC_CANCEL(); /* switch to asynchronous cancellation mode */ int result = INLINE_SYSCALL(...); LIBC_CANCEL_RESET(oldtype); According to POSIX: The side-effects of acting upon a cancellation request while suspended during a call of a function are the same as the side-effects that may be seen in a single