perl multiple tasks problem

Posted by Alice Wozownik on Stack Overflow See other posts from Stack Overflow or by Alice Wozownik
Published on 2010-06-18T01:04:02Z Indexed on 2010/06/18 1:13 UTC
Read the original article Hit count: 464

I have finished my earlier multithreaded program that uses perl threads and it works on my system. The problem is that on some systems that it needs to run on, thread support is not compiled into perl and I cannot install additional packages. I therefore need to use something other than threads, and I am moving my code to using fork(). This works on my windows system in starting the subtasks.

A few problems:

  1. How to determine when the child process exits? I created new threads when the thread count was below a certain value, I need to keep track of how many threads are running. For processes, how do I know when one exits so I can keep track of how many exist at the time, incrementing a counter when one is created and decrementing when one exits?

  2. Is file I/O using handles obtained with OPEN when opened by the parent process safe in the child process? I need to append to a file for each of the child processes, is this safe on unix as well.

  3. Is there any alternative to fork and threads? I tried use Parallel::ForkManager, but that isn't installed on my system (use Parallel::ForkManager; gave an error) and I absolutely require that my perl script work on all unix/windows systems without installing any additional modules.

© Stack Overflow or respective owner

Related posts about perl

Related posts about multithreading