Re: [PHP] Running a script without flowing

2001-03-30 Thread Mukul Sabharwal

hey,

exec("foo > /some/file 2>&1 &");
or register_shut_down("whatever");

incase it's a C program that does the math, you could
make it a daemon like thing: and do that math in the
main :-)

#include 
#include 
#include 
#include 
#include 
#include 
#include 

// copyright 2001, mukul sabharwal [[EMAIL PROTECTED]]


void get_into_background(void)
{ 
pid_t pid;


// all the familiar kitchenware!


pid = fork();
if(pid != 0)
  exit(0);


setsid(); // sets out process and group id as
part of the session
  // but only if the process ain't a
leader, hehe


close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);

// the program shouldn't acquire a terminal

signal(SIGHUP, SIG_IGN); // incase we get
HUP'd, ignore!

pid = fork();
if(pid != 0)
  exit(0);

chdir("/towhere");
umask(0);
}

void the_actual_exec(void)
{
char buffer[1024];
char *args[3];


args[0] = "ls";
args[1] = "-F";
args[2] = 0;

execv("/bin/ls", args); // 0 terminated array
perror("execv"); // as exec dont return
nutting
 // going past exec is an
ERROR
}



int main(int argc, char **argv)
{
get_into_background();
the_actual_exec();
return 0;
}

=
To find out more about me : http://www.geocities.com/mimodit
My bookmarks are available @ http://mukul.free.fr

__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Running a script without flowing

2001-03-29 Thread Jonathan Chum

I'm not sure of the exact term, but what I want todo is run a function
in a loop so that it doesn't wait for the function to finish and goes
ahead and executes the next in loop.

For example:

5; $i++) {

run_this();

}

?>

run_this may contain some long mathematical computations that takes a
while, but I want the script to go ahead and continue with the script
while the script computates...

or better yet, executes a shell script that runs in the bg, but the
PHP can safely quit without waiting for results of the shell script.
Any ideas?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]