Skip to contentSkip to conversation

Problem : can't make pipe non-blocking on 2.5.X

DISCUSSION Jean Tourrilhes 3 participants 5 messages Aug 14, 2002

lore
Share & tools
lore
#0 lore raw
	Hi,

	I've got the following problem : I can't make a pipe

non-blocking with 2.5.25.
The various man pages don't mention anything
about it (actually, the "fifo" man page say that non-blocking mode should succeed). And it seems to work fine on 2.4.20.
Sorry if this has already been reported and fixed, but I
quicly searched the changelog and archive and found nothing.

So, who should I complain to ?

------------- Setup ------------------------

	Kernel : 2.5.25 fails (but 2.4.20-pre2 works)
	Distrib : Debian 3.0
	libc : 2.2.5

------------- Test program -----------------
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>

int main()
{
int trigger_pipe[2];
int err;
int flags;

  pipe(trigger_pipe);

err = fcntl(trigger_pipe[0], F_GETFL, &flags); fprintf(stderr, "GET FLAGS : %d - %X\n", err, flags); if(err >= 0)

    {
      flags |= O_NONBLOCK;
      err = fcntl(trigger_pipe[0], F_SETFL, flags);
      fprintf(stderr, "SET FLAGS : %d - %d\n", err, errno);
    }

return(0);
}
------------- Output 2.5.25 ----------------
GET FLAGS : 0 - 40045F18
SET FLAGS : -1 - 22
------------- Output 2.4.20-pre2 -----------
GET FLAGS : 0 - 40043F18
SET FLAGS : 0 - 0
--------------------------------------------

	Have fun...

	Jean
#1 lore raw
Quoted 3 lines · Jean Tourrilhes
  pipe(trigger_pipe);
    if((flags = fcntl(trigger_pipe[0], F_GETFL)) != -1);
       flags &= ~O_NDELAY;
    fcntl(trigger_pipe[0], F_SETFL, flags);

Cheers,
Dick Johnson
Penguin : Linux version 2.4.19 on an i686 machine (797.90 BogoMips). The US military has given us many words, FUBAR, SNAFU, now ENRON. Yes, top management were graduates of West Point and Annapolis.

#2 lore raw
Quoted 8 lines · Richard B. Johnson
Quoted 3 lines · Jean Tourrilhes
  pipe(trigger_pipe);
    if((flags = fcntl(trigger_pipe[0], F_GETFL)) != -1);
       flags &= ~O_NDELAY;
    fcntl(trigger_pipe[0], F_SETFL, flags);

Same error. Please try again.

Jean

#3 lore raw
In reply to Jean Tourrilhes
Quoted 12 lines · Jean Tourrilhes
	Hi,

	I've got the following problem : I can't make a pipe

non-blocking with 2.5.25.
The various man pages don't mention anything
about it (actually, the "fifo" man page say that non-blocking mode should succeed). And it seems to work fine on 2.4.20.
Sorry if this has already been reported and fixed, but I
quicly searched the changelog and archive and found nothing.

So, who should I complain to ?

[...]

Quoted 1 line
  err = fcntl(trigger_pipe[0], F_GETFL, &flags);

F_GETFL should be,

    flags = fcntl(trigger_pipe[0], F_GETFL, 0);
Quoted 7 lines

fprintf(stderr, "GET FLAGS : %d - %X\n", err, flags); if(err >= 0)

    {
      flags |= O_NONBLOCK;
      err = fcntl(trigger_pipe[0], F_SETFL, flags);
      fprintf(stderr, "SET FLAGS : %d - %d\n", err, errno);
    }
Quoted 9 lines

return(0);
}
------------- Output 2.5.25 ----------------
GET FLAGS : 0 - 40045F18
SET FLAGS : -1 - 22
------------- Output 2.4.20-pre2 -----------
GET FLAGS : 0 - 40043F18
SET FLAGS : 0 - 0
--------------------------------------------

Looks like effect of different implement of O_DIRECT(0x40000). Thanks.

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#4 lore raw
Quoted 3 lines · OGAWA Hirofumi

F_GETFL should be,

    flags = fcntl(trigger_pipe[0], F_GETFL, 0);

Oups. I'll fix that. Thanks !

Quoted 10 lines
Quoted 7 lines

------------- Output 2.5.25 ----------------
GET FLAGS : 0 - 40045F18
SET FLAGS : -1 - 22
------------- Output 2.4.20-pre2 -----------
GET FLAGS : 0 - 40043F18
SET FLAGS : 0 - 0
--------------------------------------------

Looks like effect of different implement of O_DIRECT(0x40000). Thanks.

Work in progress, I guess. Thanks...

Jean