Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - C API similar to waitfor: (9 Items)
   
C API similar to waitfor  
need to wait till a path (or a device node) to exists or appear in C program. 
Is there a C API equal to waitfor command? 

best regards,
Chun
RE: C API similar to waitfor  
waitfor uses stat()

Here is an example:

int waitfor( char *path, unsigned wait_msec, unsigned wait_period_msec )
{
	struct stat		sbuf;
	unsigned		total = 0, ret;

	do {
		delay( wait_period_msec );
		total += wait_period_msec;
	} while ( (ret = stat( path, &sbuf )) == -1 && total < wait_msec );
	if ( total >= wait_msec )
		errno = ETIMEDOUT;
	return ret;
}

Chris


-----Original Message-----
From: Chun He [mailto:community-noreply@qnx.com] 
Sent: April-18-12 2:39 AM
To: general-filesystems
Subject: C API similar to waitfor

need to wait till a path (or a device node) to exists or appear in C program. 
Is there a C API equal to waitfor command? 

best regards,
Chun



_______________________________________________

General
http://community.qnx.com/sf/go/post92596
Re: C API similar to waitfor  
Actually it uses waitfor() - it's in libgen.h

:-)

On 12-04-18 10:05 AM, Chris Travis wrote:
> waitfor uses stat()
>
> Here is an example:
>
> int waitfor( char *path, unsigned wait_msec, unsigned wait_period_msec )
> {
> 	struct stat		sbuf;
> 	unsigned		total = 0, ret;
>
> 	do {
> 		delay( wait_period_msec );
> 		total += wait_period_msec;
> 	} while ( (ret = stat( path,&sbuf )) == -1&&  total<  wait_msec );
> 	if ( total>= wait_msec )
> 		errno = ETIMEDOUT;
> 	return ret;
> }
>
> Chris
>
>
> -----Original Message-----
> From: Chun He [mailto:community-noreply@qnx.com]
> Sent: April-18-12 2:39 AM
> To: general-filesystems
> Subject: C API similar to waitfor
>
> need to wait till a path (or a device node) to exists or appear in C program.
> Is there a C API equal to waitfor command?
>
> best regards,
> Chun
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post92596
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post92605
>

-- 
cburgess@qnx.com
RE: C API similar to waitfor  
Sure, but according to our documentation and the "actual?" lib/c/qnx/waitfor.c  it uses stat()  :-)
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.neutrino_utilities/w/waitfor.html
plus aside from the definition in libgen.c, waitfor() is not documented. :-(

-----Original Message-----
From: Colin Burgess [mailto:community-noreply@qnx.com] 
Sent: April-18-12 10:11 AM
To: general-filesystems
Subject: Re: C API similar to waitfor

Actually it uses waitfor() - it's in libgen.h

:-)

On 12-04-18 10:05 AM, Chris Travis wrote:
> waitfor uses stat()
>
> Here is an example:
>
> int waitfor( char *path, unsigned wait_msec, unsigned wait_period_msec 
> ) {
> 	struct stat		sbuf;
> 	unsigned		total = 0, ret;
>
> 	do {
> 		delay( wait_period_msec );
> 		total += wait_period_msec;
> 	} while ( (ret = stat( path,&sbuf )) == -1&&  total<  wait_msec );
> 	if ( total>= wait_msec )
> 		errno = ETIMEDOUT;
> 	return ret;
> }
>
> Chris
>
>
> -----Original Message-----
> From: Chun He [mailto:community-noreply@qnx.com]
> Sent: April-18-12 2:39 AM
> To: general-filesystems
> Subject: C API similar to waitfor
>
> need to wait till a path (or a device node) to exists or appear in C program.
> Is there a C API equal to waitfor command?
>
> best regards,
> Chun
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post92596
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post92605
>

--
cburgess@qnx.com




_______________________________________________

General
http://community.qnx.com/sf/go/post92606
Re: C API similar to waitfor  
waitfor() should be used so that when / if it's
changed to not poll in a loop, everyone will
benefit.

-seanb

On Wed, Apr 18, 2012 at 10:23:49AM -0400, Chris Travis wrote:
> Sure, but according to our documentation and the "actual?" lib/c/qnx/waitfor.c  it uses stat()  :-)
> http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.neutrino_utilities/w/waitfor.html
> plus aside from the definition in libgen.c, waitfor() is not documented. :-(
> 
> -----Original Message-----
> From: Colin Burgess [mailto:community-noreply@qnx.com] 
> Sent: April-18-12 10:11 AM
> To: general-filesystems
> Subject: Re: C API similar to waitfor
> 
> Actually it uses waitfor() - it's in libgen.h
> 
> :-)
> 
> On 12-04-18 10:05 AM, Chris Travis wrote:
> > waitfor uses stat()
> >
> > Here is an example:
> >
> > int waitfor( char *path, unsigned wait_msec, unsigned wait_period_msec 
> > ) {
> > 	struct stat		sbuf;
> > 	unsigned		total = 0, ret;
> >
> > 	do {
> > 		delay( wait_period_msec );
> > 		total += wait_period_msec;
> > 	} while ( (ret = stat( path,&sbuf )) == -1&&  total<  wait_msec );
> > 	if ( total>= wait_msec )
> > 		errno = ETIMEDOUT;
> > 	return ret;
> > }
> >
> > Chris
> >
> >
> > -----Original Message-----
> > From: Chun He [mailto:community-noreply@qnx.com]
> > Sent: April-18-12 2:39 AM
> > To: general-filesystems
> > Subject: C API similar to waitfor
> >
> > need to wait till a path (or a device node) to exists or appear in C program.
> > Is there a C API equal to waitfor command?
> >
> > best regards,
> > Chun
> >
> >
> >
> > _______________________________________________
> >
> > General
> > http://community.qnx.com/sf/go/post92596
> >
> >
> >
> >
> > _______________________________________________
> >
> > General
> > http://community.qnx.com/sf/go/post92605
> >
> 
> --
> cburgess@qnx.com
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post92606
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post92607
> 
Re: C API similar to waitfor  
If waitfor() doesn't use poll, it is preferred. 
Which library includes waitfor()?

Thanks for quick responses.

-Chun 
RE: C API similar to waitfor  
PR 77631 is a laundry list of undocumented functions. You'll be happy to learn that waitfor() is on the list.

Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems


-----Original Message-----
From: Chris Travis [mailto:community-noreply@qnx.com] 
Sent: Wednesday, April 18, 2012 10:24 AM
To: general-filesystems
Subject: RE: C API similar to waitfor

Sure, but according to our documentation and the "actual?" lib/c/qnx/waitfor.c  it uses stat()  :-) http://www.qnx.com/
developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.neutrino_utilities/w/waitfor.html
plus aside from the definition in libgen.c, waitfor() is not documented. :-(

Re: RE: C API similar to waitfor  
>PR 77631 is a laundry list of undocumented functions. You'll be happy to learn that waitfor() is on the list.

Is this a document that is available on this website ? Can you link to it ?
RE: RE: C API similar to waitfor  
No, I haven't written anything about waitfor() yet.

Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems


-----Original Message-----
From: Rohit Nair [mailto:community-noreply@qnx.com] 
Sent: Wednesday, April 18, 2012 2:02 PM
To: general-filesystems
Subject: Re: RE: C API similar to waitfor

>PR 77631 is a laundry list of undocumented functions. You'll be happy to learn that waitfor() is on the list.

Is this a document that is available on this website ? Can you link to it ?



_______________________________________________

General
http://community.qnx.com/sf/go/post92619