LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-03-2005, 07:46 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
C++: can you set a timeout for a system call?


I've written a simple c++ program that creates, then executes an external script with the system() function.

The problem is that sometimes the script hangs (it's trying to get data from the interenet)... is there a way to call the script from my c++ program so that it times out after, say, 5 seconds?
 
Old 06-03-2005, 08:43 PM   #2
grupoapunte
LQ Newbie
 
Registered: Apr 2005
Posts: 26

Rep: Reputation: 15
you can use alarm(5) it will deliver SIGALRM after 5 sec all you need to do is cach it and take contorl of your program again, i think there may be other ways to do what you want like using threads
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set TCP Timeout xenomage Linux - Networking 5 11-23-2009 04:08 PM
How to set timeout value in Konqueror mldqj Linux - Software 1 04-03-2004 04:42 PM
How to set timeout value when reading from a file descriptor. George2 Programming 7 10-26-2003 01:15 AM
Set dhcp timeout in Suse 8.0 neilmon2 Linux - Networking 1 10-15-2002 12:00 AM
help!!! how can i timeout a socket connect call... ? bzImage Programming 1 03-06-2002 02:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration