site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com The alternative is to use socketpair(2) Vincent On Nov 29, 2006, at 9:35 AM, Tomasz Kukielka wrote: On 11/29/06 9:26 AM, "Vincent Lubet" <vlubet@apple.com> wrote: This message is there to alert developers they should not use sockets system calls like send() and recv() on pipes as pipes are no more backed by sockets since Tiger 10.4. You should use write() and read() instead. Vincent On Nov 28, 2006, at 10:38 PM, Tomasz Kukielka wrote: Hi, I noticed the following kernel message in system log: Nov 28 20:10:42 TK-MB kernel[0]: CommandDroplet[1993] uses send/ recv on a pipe CommandDroplet is the application that I develop as part of OnMyCommand which wraps Unix or AppleScript scripts with some GUI. I have been experimenting with it recently trying to make popen execution non- blocking. The problem is with pipe caching (you cannot work it around) which locks the reading and you get stuck in in fread (or fgets). I wanted to improve it but nothing seemed to work until I created a CFSocket on the file description from the stream. It works beautifully as a CFRunLoop source - providing a data in callback and not blocking. But the kernel message is a signal that there might be something wrong with it. See below for the code I used. When I #undef USE_CFSOCKET the kernel does not complain. I would really hate to go back to the previous synchronous/blocking code. Thanks, Tom http://www.abracode.com/free/cmworkshop/ bool POpenExecutor::Execute( const char *inCommand ) { if(inCommand == NULL) return true; FILE *fp = popen( inCommand, "r" ); if ( fp != NULL ) { #ifdef USE_CFSOCKET CFSocketContext context; context.version = 0; context.info = this; context.retain = NULL; context.release = NULL; context.copyDescription = NULL; int fileDesc = fileno(fp); return false; //not finished yet #else //USE_CFSOCKET static char oneLine[1024]; oneLine[0] = 0; do { fgets (oneLine, sizeof(oneLine), fp); } while( feof(fp) == 0 ); (void) pclose( fp ); return true; //finished #endif //USE_CFSOCKET } return true; //error condition. finished } _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/vlubet% 40apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... I do not use send and recv directly, I use CFSocket abstraction which probably uses them. Does that mean that this code will break after Tiger? Or can I hope that CFSocket will be fixed to use read/write instead send/recv? I know it is kind of hackish to use CFSocketCreateWithNative on file descriptor but it works very well for me. Alternatives? Tom mFileDescSocket = ::CFSocketCreateWithNative( kCFAllocatorDefault, fileDesc, kCFSocketDataCallBack, PopenCFSocketCallback, &context); if(mFileDescSocket != NULL) { mSource = ::CFSocketCreateRunLoopSource (kCFAllocatorDefault, mFileDescSocket, 0); if(mSource != NULL) ::CFRunLoopAddSource( ::CFRunLoopGetCurrent(), mSource, kCFRunLoopDefaultMode ); } This email sent to vlubet@apple.com This email sent to site_archiver@lists.apple.com