I noticed that one of the tests fails on a standard Windows installation of SWI-prolog. The relevant code is copied below from pl-test.pl, with a few modifications in the attempt to debug it. The file is empty, no hello world in it.
Minor: The original code may cause unwanted backtracking if A == Text fails.
popen(cat-1) :- ( current_prolog_flag(windows, true) -> Cmd = 'cmd /c type con' % "type con" is cmd-speak for "cat /dev/stdin" ; Cmd = cat ), current_prolog_flag(pid, Pid), format(atom(File), 'pltest-~w.txt', [Pid]), Text = 'Hello World', atomic_list_concat([Cmd, ' > ', File], Command), atom_string(Command, CommandStr), writeln("opening file"), open(pipe(CommandStr), write, Fd), writeln(Fd, Text), % nothing is written here flush_output(Fd), close(Fd), writeln("file has been written":File), !, writeln("opening file for reading":File), open(File, read, Fd2), collect_data(Fd2, String), close(Fd2), writeln("file has been read"), % delete_file(File), atom_codes(A, String), % A == Text, writeln(result:A). collect_data(Fd, String) :- get0(Fd, C0), collect_data(C0, Fd, String). collect_data(-1, _, ) :- !. collect_data(C, Fd, [C|T]) :- get0(Fd, C2), collect_data(C2, Fd, T).