public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* error setting pipe to non-blocking IO
@ 2003-10-17 22:41 Andy Howell
  2003-10-18  1:03 ` Brian Ford
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Howell @ 2003-10-17 22:41 UTC (permalink / raw)
  To: cygwin

I am trying to setup a pipe to do non-blocking IO:

int main()
{
	int pipefd[2];
	int n;
	n = 1;
	
	pipe(pipefd);
	perror("Pipe: ");
	ioctl(pipefd[0], FIOBIO, &n);
	perror("Ioctl: ");
}

When I run this, I get:

Pipe: No Error
Ioctl: Invalid argument

Any ideas?

Thanks,

	Andy
	


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: error setting pipe to non-blocking IO
  2003-10-17 22:41 error setting pipe to non-blocking IO Andy Howell
@ 2003-10-18  1:03 ` Brian Ford
  2003-10-18  2:11   ` Brian Ford
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Ford @ 2003-10-18  1:03 UTC (permalink / raw)
  To: Andy Howell; +Cc: cygwin

On Fri, 17 Oct 2003, Andy Howell wrote:

> I am trying to setup a pipe to do non-blocking IO:
>
> int main()
> {
> 	int pipefd[2];
> 	int n;
> 	n = 1;
>
> 	pipe(pipefd);
> 	perror("Pipe: ");
> 	ioctl(pipefd[0], FIOBIO, &n);
> 	perror("Ioctl: ");
> }
>
> When I run this, I get:
>
> Pipe: No Error
> Ioctl: Invalid argument
>
> Any ideas?
>
Yup, unsupported.

from src/winsup/cygwin/fhandler.cc:909

int
fhandler_base::ioctl (unsigned int cmd, void *buf)
{
  if (cmd == FIONBIO)
    syscall_printf ("ioctl (FIONBIO, %p)", buf);
  else
    syscall_printf ("ioctl (%x, %p)", cmd, buf);

  set_errno (EINVAL);
  return -1;
}

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: error setting pipe to non-blocking IO
  2003-10-18  1:03 ` Brian Ford
@ 2003-10-18  2:11   ` Brian Ford
  2003-10-18  3:46     ` Andy Howell
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Ford @ 2003-10-18  2:11 UTC (permalink / raw)
  To: cygwin

Actually, it looks like this might work. YMMV

On Fri, 17 Oct 2003, Brian Ford wrote:

> On Fri, 17 Oct 2003, Andy Howell wrote:
>
> > I am trying to setup a pipe to do non-blocking IO:
> >
> > int main()
> > {
> > 	int pipefd[2];
> > 	int n;
> > 	n = 1;
> >
> > 	pipe(pipefd);
> > 	perror("Pipe: ");
> > 	ioctl(pipefd[0], FIOBIO, &n);
> >
use:
        fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
instead.

PTC for FIOBIO, although I can't even find what header that's in?

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: error setting pipe to non-blocking IO
  2003-10-18  2:11   ` Brian Ford
@ 2003-10-18  3:46     ` Andy Howell
  2003-10-27 19:17       ` Brian Ford
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Howell @ 2003-10-18  3:46 UTC (permalink / raw)
  To: Brian Ford, cygwin

Brian Ford wrote:

>>>	ioctl(pipefd[0], FIOBIO, &n);

> use:
>         fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
> instead.
> 
> PTC for FIOBIO, although I can't even find what header that's in?

fcntl did the trick. Thanks. FIONBIO come from sys/termios.h. I 
mis-spelled it in my message.

Thanks again,

	Andy





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: error setting pipe to non-blocking IO
  2003-10-18  3:46     ` Andy Howell
@ 2003-10-27 19:17       ` Brian Ford
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Ford @ 2003-10-27 19:17 UTC (permalink / raw)
  To: Andy Howell; +Cc: cygwin

This should now be supported in the latest snapshot available at:

http://www.cygwin.com/snapshots

Please test and confirm if you are so inclined.  Thanks.

On Fri, 17 Oct 2003, Andy Howell wrote:
> Brian Ford wrote:
> > Andy Howell wrote:
> >>	ioctl(pipefd[0], FIONBIO, &n);
> >>
> > use:
> >         fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
> > instead.
> >
> > PTC for FIONBIO, although I can't even find what header that's in?
>
> fcntl did the trick. Thanks. FIONBIO come from sys/termios.h. I
> mis-spelled it in my message.
>

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-27 17:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-17 22:41 error setting pipe to non-blocking IO Andy Howell
2003-10-18  1:03 ` Brian Ford
2003-10-18  2:11   ` Brian Ford
2003-10-18  3:46     ` Andy Howell
2003-10-27 19:17       ` Brian Ford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).