Note that there are some explanatory texts on larger screens.

plurals
  1. POfork() creates run-time error, am I using it correctly?
    primarykey
    data
    text
    <p>I have a Perl program that I've written that parses SQL-like statements and creates a job to run on a mainframe that extracts fields and records based on the criteria. The records are returned to the PC and then output in various formats (e.g. csv, XML, etc.). I co-opted SQL's INTO clause to list the files and outputs.</p> <p>The issue is that writing records to a SQLite database (one of the output formats) takes a relatively long time and I don't want that to hold up the processing of the next SQL command (in case there are multiple SQL queries passed in). So, I thought I would use fork() to make this happen.</p> <p>The original bit of code is:</p> <pre><code>foreach (@into) { dointo($_,$recs); } </code></pre> <p>@into is a list of files and formats (e.g. 'File1.csv' is a comma-delimited format sent to File1.csv, 'File1.xml' is an XML format written to File1.xml, etc.) to be processed. The subroutine dointo handles each of these. $recs is a sort of iterator that returns records in a variety of formats (flat, anonhash, anonarray, etc.)</p> <p>So, I changed the code to:</p> <pre><code>foreach (@into) { unless (fork()) { dointo($_,$recs); exit 0; } } </code></pre> <p>but now when the code runs, it seems to work, but it pulls a run-time error every time.</p> <p>I didn't capture the return from fork() because I really don't care about waiting for the forked process to finish. Could this be the error? Does the parent process NEED to wait for the child processes to finish before it can safely exit?</p> <p>Any help would be appreciated.</p> <p>(BTW, Windows XP is the OS, Activestate Perl 5.10.0 is the Perl version)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload