Re: Running a script without flowing

From: Date: Fri, 30 Mar 2001 10:13:13 +0000
Subject: Re: Running a script without flowing
Groups: php.general 
Request: Send a blank email to php-general+get-46290@lists.php.net to get a copy of this message
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 <sys/types.h> #include <sys/time.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <signal.h> #include <unistd.h> // copyright 2001, mukul sabharwal [mukul@devhome.net] 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

« previous php.general (#46290) next »