« Return to Thread: Gprolog 1.4 exec/5 does not work under cygwin

Re: Gprolog 1.4 exec/5 does not work under cygwin

by Mark Utting :: Rate this Message:

| View in Thread

Daniel Diaz-3 wrote:
    A first remark without looking at details...
   
    The gprolog version you downloaded is a native Windows app. It does
    not know nothing about cygwin.
    In particular bash or /bin cannot be resolved.
    You can try passing 'c:/cygwin/bin/echo abc' to see if it is better.
    For instance try:
   
    exec('dir', I,O,E,P), repeat, get_char(O,T), write(T), T = end_of_file, !, wait(P,S).

    What do you obtain ?

Interesting, I get this:


$ gprolog
GNU Prolog 1.4.0
By Daniel Diaz
Copyright (C) 1999-2011 Daniel Diaz
| ?- exec('dir', I,O,E,P), repeat, get_char(O,T), write(T),  T = end_of_file, !, wait(P,S).
 Volume in drive C is OS
 Volume Serial Number is F44F-E564

 Directory of C:\marku\starlog\trunk

12/12/2011  12:31 PM    <DIR>          .
12/12/2011  12:31 PM    <DIR>          ..
13/12/2011  02:13 PM    <DIR>          .svn
12/12/2011  12:30 PM    <DIR>          art
12/12/2011  12:31 PM    <DIR>          cuda
12/12/2011  12:31 PM    <DIR>          doc
...
               0 File(s)              0 bytes
              31 Dir(s)  314,787,344,384 bytes free
end_of_file

uncaught exception: error(system_error('No child processes'),wait/2)
| ?-


which shows that the exec is working, but the wait is not (perhaps the child process is not being kept around as a zombie until the wait?)


>    or
>    exec('c:/cygwin/bin/echo abc', I,O,E,P), repeat, get_char(O,T), write(T),  T = end_of_file, !, wait(P,S).
>    What do you obtain ?


Same result.  
I did this twice - the first time with a non-existent executable and the second time with the correct path to cygwin echo.


$ gprolog
GNU Prolog 1.4.0
By Daniel Diaz
Copyright (C) 1999-2011 Daniel Diaz
| ?- exec('c:/cygwin/bin/echo abc', I,O,E,P), repeat, get_char(O,T), write(T),  T = end_of_file, !, wait(P,S).
end_of_file

uncaught exception: error(system_error('No child processes'),wait/2)
| ?- exec('c:/Apps/cygwin/bin/echo abc', I,O,E,P), repeat, get_char(O,T), write(T),  T = end_of_file, !, wait(P,S).
abc
end_of_file

uncaught exception: error(system_error('No child processes'),wait/2)
| ?-

 


>    If you want a pure cygwin app you should download a source .tar.gz package and build it under cygwin.


Yes, I've tried that.  It builds and installs successfully, but I get the same problem with wait/2:


Mark.Utting@RWS034 /cygdrive/c/Apps/gprolog-1.4.0/src
$ which gprolog
/usr/local/bin/gprolog


$ gprolog
GNU Prolog 1.4.0
By Daniel Diaz
Copyright (C) 1999-2011 Daniel Diaz
| ?- exec('dir', I,O,E,P), repeat, get_char(O,T), write(T),  T = end_of_file, !, wait(P,S).
 Volume in drive C is OS
 Volume Serial Number is F44F-E564

 Directory of C:\Apps\gprolog-1.4.0\src

14/12/2011  06:01 AM    <DIR>          .
14/12/2011  06:01 AM    <DIR>          ..
17/12/2008  02:36 AM             4,131 .indent.pro
18/06/1999  05:53 PM             7,832 AUTOCONF-INFO
14/12/2011  06:00 AM    <DIR>          BipsFD
14/12/2011  05:59 AM    <DIR>          BipsPl
...
              22 File(s)        414,279 bytes
              16 Dir(s)  314,768,809,984 bytes free
end_of_file

uncaught exception: error(system_error('No child processes'),wait/2)
| ?-


> Does the gprolog 1.4.0 wait/2 call work on your Windows machine?

Ordinary C programs that use exec and wait seem to work fine,
for example the fork-03.c program here: http://www.csl.mtu.edu/cs4411/www/NOTES/process/fork/wait.html  seems to produce the expected output.


Thanks
Mark


   

 « Return to Thread: Gprolog 1.4 exec/5 does not work under cygwin