Results 1 to 3 of 3
hi all
how can i sleep a command that is popen("xxxxxx","r");
to two seconds.
i wrote my program like this
popen("xxxxxx","r");
sleep(2)
popen("xxxxxx","r");
but it is not waiting for 2 ...
- 05-15-2007 #1Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
wait for 2 seconds
hi all
how can i sleep a command that is popen("xxxxxx","r");
to two seconds.
i wrote my program like this
popen("xxxxxx","r");
sleep(2)
popen("xxxxxx","r");
but it is not waiting for 2 seconds. it is directly excuting.
it have to wait to excute the second popen()
how can i do?, is there any other way to wait for 2 seconds.
please help me
thank you in advance"Relationships are built on trust and communication"
- 05-15-2007 #2
I'm a little bit confused...
You want to wait 2 seconds before running popen? Then simply remove the first popen.
If you want to run popen and timeout after 2 seconds, the only way I can think of would be starting a separate thread and passing a reference to the FILE* to the starting function. Then use that separate thread to run popen, with a sleep call in the main thread. After sleep returns, you kill the thread if it's not already exited, and then you can check the status of the FILE* you passed in.
There may be a simpler way to do the latter, but I'm not sure what it would be.DISTRO=Arch
Registered Linux User #388732
- 05-15-2007 #3Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Check this reply:
http://www.linuxforums.org/forum/lin...tml#post467213
Regards


Reply With Quote