in reply to Re: segmentation fault
in thread segmentation fault

Actually, I think it should be written as
my @command = ( 'cfi', '-N', $bsc, '-l', "RLSTP:CELL=$cell;" ); open( CFI "-|", @command ) or die "unable to run \"@command\": $!";
Using an array to store the individual command-line tokens means that you don't need to worry about quoting or escaping shell-magic characters (like ";").

Replies are listed 'Best First'.
Re^3: segmentation fault
by lbarbago (Initiate) on Sep 23, 2009 at 06:47 UTC

    Thanks for your answers. I donīt really think the $command's format is the key, but I will change it to see it goes better. Anyway, how can I check the return value of open an close in an easy way?, because I really think the problem is there, in fact I use the "truss" linux command and I got some Err#9 EBADF (/* Bad file descriptor */)

      how can I check the return value of open an close in an easy way?

      In what sense is open( ... ) or die "..." not sufficient for you? (The same works for "close", but in a unix/linux environment, it's unlikely closing a file handle will ever be a problem -- I gather it can be an issue on mswindows.)

      If there are still problems with running the sub-process from within the script, you should print the command line to STDERR before trying to execute it, so you can see what the sub-shell is being given, and then try running that manually to see what happens. Given that the segfaults are intermittent, they are caused either by the data being used to build the command line, or else by other conditions on your machine that are external to your perl script. (If the script starts multiple sub-processes within a single run, there's also a possibility of interference or confusion among sub-processes.)