![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Linux Gurus - Problem
I'm exec()'ing a bourne shell program from PHP. For the moment, it is not possible to port this shell program to php. I also do not have access to the source.
The shell program is fed instructions from the php file which grabs them from a ascii file. The simplified php process is: while not eof datafile { fgets(arg) exec(program arg) } However, executing the program sometimes gets locked into loops where it will just sit there. I want to have some way to put a time limit. Setting the script to call another php script (that only execs the program) with a maximum exec time will not work - max times are only while inside the php script. And the bash ulimit can only control processor time used, not actually kill the program, correct? Ideally I'd like do run something like: exec (./timelimit5 program arg) which would just kill the process if it exceeds 5 seconds. But I'm lost. Any suggestions? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: May 2002
Posts: 258
|
I'm not a Linux guru, but aren't shell programs unix commands in a plain file ? Shell programs are not compiled are they ? So you should have the source and be able to put a kind of timeout there no?
Well, just what I see from your post.
__________________
"Bite my shiny metal ass!" |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2004
Posts: 8
|
![]() First of all, I would recomand rewriting it in Perl.
If you want to keep it in bash, try to use signals, something like this http://www.signaltonoise.net/library...ariables2.html Or search Google for "bash timeout script" [in a nutshell] TimerOn() { ( o p e n accolade thingy here, obfuscate by GFY board code) sleep $TIMELIMIT && kill -s 14 $$ & # Waits XXX seconds, then sends sigalarm to script. } [...] trap Int14Vector 14 #Int14Vector is a function called when sig 14 is traped by script See sleep, kill and trap for details. HIH |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
I apologize - judging from the replies - I wasn't clear.
The program I am execing is a compiled C app under bash, it isn't a bash script. That is why I don't have the source. I can't rewrite it ![]() flexor - thanks for the reply though, I will put that stuff into my "learning" notebook I keep for when I'm doing something in perl. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Alarm did it. Many many many thanks.
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |