[GAP Forum] Bug in Process()

Frank Heckenbach heckenb at mi.uni-erlangen.de
Tue Apr 20 00:43:14 BST 2004


Dear Gap-Forum,

it seems to become a tradition for me to find a bug related to
Process() in each new release. ;-) With GAP 4.4.2 I see this:

  gap> s := "";;
  gap> out := OutputTextString (s, true);;
  gap> inp := InputTextFile ("/dev/null");;
  gap> Process (DirectoryCurrent(), "/bin/true", inp, out, []);;
  gap> DirectoryTemporary ();;
  gap> Process (DirectoryCurrent(), "/bin/true", inp, out, []);;
  List Element: <list> must be a list (not a boolean) at
  return ExecuteProcess( dir, prg, input![1], output![1], args );
   called from
  EXECUTE_PROCESS_FILE_STREAM( dir, prg, input, new_output, args ) called from
  <function>( <arguments> ) called from read-eval-loop
  Entering break read-eval-print loop ...
  you can 'quit;' to quit to outer loop, or
  you can replace <list> via 'return <list>;' to continue

The problem seems to be the caching of `PROCESS_INPUT_TEMPORARY' and
`PROCESS_OUTPUT_TEMPORARY' in `process.gi' while the corresponding
files are erased. `TmpName' or `DirectoryTemporary' then seem to
reuse the name (I assume this is intended).

If it's reused as a directory which still exists (like here), this
will fail and result in `new_output = fail', leading to the error
shown. (If it's reused as a file, it may silently overwrite that
file; I haven't checked this case.)

Quick fix:

--- gap4r4/lib/process.gi.orig	Mon Apr 19 03:22:39 2004
+++ gap4r4/lib/process.gi	Mon Apr 19 03:31:20 2004
@@ -148,9 +148,6 @@
 #M  Process( <dir>, <prg>, <input>, <output>, <args> )  . . . . stream/stream
 ##
 
-PROCESS_INPUT_TEMPORARY := fail;
-PROCESS_OUTPUT_TEMPORARY := fail;
-
 InstallMethod( Process,
     [ IsDirectory and IsDirectoryRep,
       IsString,
@@ -162,10 +159,9 @@
 
     # convert input into a file
     if not IsInputTextFileRep(input)  then
-        while PROCESS_INPUT_TEMPORARY = fail do
-            PROCESS_INPUT_TEMPORARY := TmpName();
-        od;
-        name_input := PROCESS_INPUT_TEMPORARY;
+        repeat
+            name_input := TmpName();
+        until name_input <> fail;
         new := OutputTextFile( name_input, true );
         allinput := ReadAll(input);
         if allinput= fail then
@@ -178,10 +174,9 @@
 
     # convert output into a file
     if not IsOutputTextFileRep(output)  then
-        while PROCESS_OUTPUT_TEMPORARY = fail do
-            PROCESS_OUTPUT_TEMPORARY := TmpName();
-        od;
-        name_output := PROCESS_OUTPUT_TEMPORARY;
+        repeat
+            name_output := TmpName();
+        until name_output <> fail;
         new_output  := OutputTextFile( name_output, true );
     else
         new_output  := output;

Frank Heckenbach

-- 
Frank Heckenbach, heckenb at mi.uni-erlangen.de
http://www.mi.uni-erlangen.de/~heckenb/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)




More information about the Forum mailing list