how to test if a pipe contains data

Gilles Espinasse g.esp at free.fr
Mon Jan 23 20:46:47 UTC 2012


----- Original Message ----- 
From: "Christof Warlich" <christof at warlich.name>
To: "Harald Becker" <ralda at address4me.eu>
Cc: <busybox at busybox.net>
Sent: Monday, January 23, 2012 7:42 PM
Subject: Re: how to test if a pipe contains data


> Am 23.01.2012 09:43, schrieb Harald Becker:
> > Hallo Laurent!
> >
> >>> Anyhow, if it helps, or even if someone is interested, I'm happy to
> >>> explain in detail why I need to peek for data on a filedescriptor.
> >>   I'd be interested in knowing why you need to do that. Maybe, by
> >> looking at the big picture, we can help you design a solution that
> >> fulfills your needs without this particular issue.
> > You hit it exactly. Beside this I'm willing to help finding a solution
> > and to do not only complain ... but it's absolute necessary to have the
> > full picture to say anything about this.
> >
> > --
> > Harald
>
> I need to transfer data coming from a pipe over a UMTS link to a web
server.
>  From time to time, the UMTS link goes down, and worse, it sometimes
cannot
> be reestablished. I believe that in these cases, the firmware of the
> UMTS stick
> hangs, but this is just a guess. Anyhow, the only way I could get the
> link up and
> running again when this happens is to reboot the whole system.
>
> As my application will have tried for quite a while to get the link up
> before such drastic measures, quite some data may have accumulated in the
pipe.
> To avoid loosing that data, I need to drain the pipe to store its data
> to a file surviving the recovery. This is the place where I just want to
check if
> there is still data in the pipe. If it is empty, I reboot.

If the stick is usb-powered, you may find more convenient than reboot to
just reset or maybe unpower usb.
I made usb reset with 2.4 kernel on the time of usb adsl modem using
modprobe -r / modprobe with hcd module.

Gilles



More information about the busybox mailing list