I would appreciate any insight regarding a problem I’m experiencing. An exception when I close the stderr pipe via
process:process_create(‘/tmp/duma.sh’, [stdout(pipe(Out)), stderr(pipe(Err))])
The file duma.sh does not exist.
The following is correctly handled and stderr pipe is closed because dum.sh exists and writes one line to each of stdout and one to stderr.
process:process_create('/tmp/dum.sh', [stdout(pipe(Out)), stderr(pipe(Err))]), writeln(Out), writeln(Err), read_line_to_string(Out,OutStr), read_line_to_string(Err,ErrStr), (nonvar(Out) -> close(Out);true), (nonvar(Err) -> close(Err);true).
Out = <stream>(0x3dd9c00),
Err = <stream>(0x3dd9d00),
OutStr = "From dum to stdout",
ErrStr = "From dum to stderr".
However if the file doesn’t exist, an exception is generated during closure of stderr (though it is closed)
process:process_create('/tmp/duma.sh', [stdout(pipe(Out)), stderr(pipe(Err))]), writeln(Out), writeln(Err), read_line_to_string(Out,OutStr), read_line_to_string(Err,ErrStr), (nonvar(Out) -> close(Out);true), (nonvar(Err) -> close(Err);true).
ERROR: Process "/tmp/duma.sh": exit status: 1
ERROR: In:
ERROR: [11] close(<stream>(0x3ddf100))
ERROR: [10] '<meta-call>'(user:user: ...) <foreign>
ERROR: [9] toplevel_call(user:user: ...) at /usr/local/lib/swipl/boot/toplevel.pl:1158
Exception: (11) close(<stream>(0x3ddf100)) ? creep
To avoid the exception and don’t close the stderr pipe, we end up with hundreds of pipes. (Each run is about 30K processes). swipl is a very long running process.
Versions: 8.4.3 and 9.0.4
PS Yes the absolute_file_name check in process_create/3 mitigates this particular problem, but I’ve tried to simplify the issue in preference to more significant execution failures. I do use catch for exception handling, but I’d rather understand the problem