• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Kernel log: app uses send/recv on a pipe
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Kernel log: app uses send/recv on a pipe


  • Subject: Re: Kernel log: app uses send/recv on a pipe
  • From: Tomasz Kukielka <email@hidden>
  • Date: Wed, 29 Nov 2006 09:35:09 -0800
  • Thread-topic: Kernel log: app uses send/recv on a pipe

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

On 11/29/06 9:26 AM, "Vincent Lubet" <email@hidden> 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);
>>
>>         mFileDescSocket = ::CFSocketCreateWithNative(
>>                                                 kCFAllocatorDefault,
>> fileDesc, kCFSocketDataCallBack,
>>                                                 PopenCFSocketCallback,
>> &context);
>>         if(mFileDescSocket != NULL)
>>         {
>>             mSource = ::CFSocketCreateRunLoopSource
>> (kCFAllocatorDefault,
>> mFileDescSocket, 0);
>>             if(mSource != NULL)
>>                 ::CFRunLoopAddSource( ::CFRunLoopGetCurrent(),
>> mSource,
>> kCFRunLoopDefaultMode );
>>         }
>>
>>         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      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40apple.com
>>
>> This email sent to email@hidden
>
>
>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Kernel log: app uses send/recv on a pipe
      • From: Vincent Lubet <email@hidden>
References: 
 >Re: Kernel log: app uses send/recv on a pipe (From: Vincent Lubet <email@hidden>)

  • Prev by Date: Re: Kernel log: app uses send/recv on a pipe
  • Next by Date: Re: Kernel log: app uses send/recv on a pipe
  • Previous by thread: Re: Kernel log: app uses send/recv on a pipe
  • Next by thread: Re: Kernel log: app uses send/recv on a pipe
  • Index(es):
    • Date
    • Thread