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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-31-2004, 07:40 AM   #1
Dusen
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?
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-31-2004, 07:53 AM   #2
Benja
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!"
Benja is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-31-2004, 08:44 AM   #3
flexor
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
flexor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-31-2004, 09:06 AM   #4
Dusen
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.
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-31-2004, 09:08 AM   #5
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
Check out "alarm" at http://void.lv/tools/

It should do what you need.
__________________
I like pie.
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-31-2004, 09:36 AM   #6
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
Alarm did it. Many many many thanks.

__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.