in reply to Reminder program

Well first of all congrats to your first posting! It would be easier to read if you'use html tags to format your post. See also the Site How To.

To your questions: It is possible to run 4 scripts simultanously by using the fork function. Ifyou are running a unix like OS this should work, i don't know about windows systems though.
Back to fork -- er work: The fork function will create a new process and return the process id of the created process - known as child process. The Camel Book states the safest way to check fork for errors:

FORK: { if ($pid == fork){ #deal with the parent process #pid of child is stored in $pid }elsif (defined $pid){ #handling child process #parent pid is available via the getppid function }elsif ($! =~/No more processes/){ # EAGAIN, this error we should be able to fix sleep 5; redo FORK; } else { #this should'nt happen at all die "cannot execute fork: $!\n"; }

Don't forget to do a reset on all your open buffers with setting $|. To avoid Zombies you should wait for your childs to exit. Use always the exit() function to end a process! The function used to wait for a child is as you may have guessed wait wait will wait and return whenever a child process exits. The status of the process is then stored in $? and the return value represents the process id of the exiting child process. If there is no child process at al you will get a -1 back. Another way to avoid Zombies is to install a Signal handler that will take care of you SIGCHLD signals: $SIG{CHLD} = sub(wait);

I hope this is enough to get you going. For reference use perldoc -f fork and perldoc -f wait.

Regards,
C-Keen

Edit by tye

Replies are listed 'Best First'.
Re: Running more than one process (the very basics)
by bsdbudha (Initiate) on Oct 02, 2001 at 01:41 UTC
    well i tried fork(); before the subroutine calls, and it hangs as usual
    i'll give those perldocs a look
    remember, i want to execute 4 subroutines at once, each doing a system call to `cat file`..
    and all 4 subroutines have an infinite loop with a sleep statement inside...
      I am not sure if i got your problem right. Would you please post your code or something that will clarify the problem?

      C-Keen

        thx for sticking to the post : }
        fork();
        &a_sched;
        fork();
        &b_sched;
        fork();
        &c_sched;
        fork();
        &d_sched;
        fork();
        &e_sched;

        sub a_sched
        {
        $var = `cat a.sched`;
        print $var;
        for(;;){
        sleep 1209600;
        print $var;
        }
        }
        each *_sched sub is the same except the cat file is different
        and the number of seconds to sleep.
        what I want to do is execute each subroutine simutaneously,
        so all the reminders print at once (cat), and they keep printing depending on the sleep. maybe my use of sleep is wrong,

        any ideas much appreciated.