Regarding select() on PPC

Sadashiiv, Halesh halesh.sadashiv at
Tue Sep 23 14:50:00 EST 2008


The below testcase requires to exit with setting errno as EINVAL, as per
the man page.

I tested this on ARM, I686, PPC64 it was fine, for the same on PPC32 it
used exit with errno set as EFAULT.

On further investigation found there was some long obsolete code in
arch/powerpc/kernel/syscalls.c (function ppc_select()), which was
written in 2.2.0 kernel for PPC32 specific , which resulted in EFAULT.

This needs to be verified, I have proposed patch for PPC32, Please check
the link

Please find the below testcase.

#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdlib.h>

int main()

 int fd;
 fd_set rfds;
 struct timeval tv;
 int ret_val;

 if ((fd = open("test_file", O_RDWR|O_CREAT, 0664)) < 0)
    printf("Open failed\n");

  FD_SET(fd, &rfds);

  /* Wait up to five seconds. */
  tv.tv_sec = 1;
  tv.tv_usec = 0;

  if ( (ret_val = select(-1, &rfds, NULL, NULL, &tv)) < 0)
    if ( errno == EINVAL)
      printf("Not OK, Got errno %d\n", errno);


>-----Original Message-----
>From: Benjamin Herrenschmidt [mailto:benh at]
>Sent: Tuesday, September 23, 2008 10:12 AM
>To: Josh Boyer
>Cc: Sadashiiv, Halesh; linuxppc-embedded at
>Subject: Re: Regarding select() on PPC
>On Mon, 2008-09-22 at 11:24 -0400, Josh Boyer wrote:
>> On Mon, Sep 22, 2008 at 08:45:52PM +0530, Sadashiiv, Halesh wrote:
>> >
>> >
>> >The issue is found only in PPC32.
>> >
>> >Please let me if the patch is applicable.
>> Well, no not really.  Mostly because of procedural issues than
>> else.  Read Documentation/SubmittingPatches in the kernel directory.
>> Also, there is a comment above this function that eludes to some
>> with select on ppc32.  You might want to ask the overall PowerPC
>> if that issue still exits.
>I have only half of this thread, what is the problem ?

This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.

More information about the Linuxppc-embedded mailing list