# Possible Bug with Pengines+Process+Windows

**URL:** <https://swi-prolog.discourse.group/t/possible-bug-with-pengines-process-windows/5622>\
**Category:** Help!\
**Tags:** bug\
**Created:** [July 19, 2022, 7:53am UTC](https://swi-prolog.discourse.group/t/possible-bug-with-pengines-process-windows/5622 "2022-07-19T07:53:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![firefrorefiddle](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/firefrorefiddle/32/4619_2.png) [@firefrorefiddle](https://swi-prolog.discourse.group/u/firefrorefiddle)\
**Post date:** [July 19, 2022, 7:53am UTC](https://swi-prolog.discourse.group/t/possible-bug-with-pengines-process-windows/5622/1 "2022-07-19T07:53:38Z")

</div>

Hi!

I’m using: SWI-Prolog version 8.2.4 on Windows.

Consider this use case: I am running a program which connects to a database and performs some calculations. When I run it from my home, it’s much slower than running from a company server because it goes through the VPN. Therefore, I want to run it remotely. I tried to use `pengine_rpc` for this. I created a pengine server which does nothing but run a program with `create_process` and write back the output. I would like to connect to this server from another machine (my laptop), but so far, I have only tested it locally.

On Linux, this works as expected. On Windows 10, the rpc call gets stuck _until I query the same predicate on the server prolog instance_.

To clarify:

## Linux:

swipl instance 1:

- start http\_server with pengines.
- query pengine\_rpc(localhost… run…) → works immediately.  
swipl instance 2:
- query pengine\_rpc(localhost… run…) → works immediately.

## Windows

swipl instance 1:

- start http\_server with pengines.
- query `pengine_rpc(localhost... run...)` → works immediately.  
swipl instance 2:
- query `pengine_rpc(localhost... run...)` → is stuck.  
Back to instance 1:
- query `run(...)` → works immediately _and also the query in instance 2 finishes_. `pengines_rpc(..., member(X,[1,2]))` or similar on the server also works for this purpose, but queries that are neither process- nor pengines-related don’t.

My code looks like this:

server.pl:

```prolog
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- http_server(http_dispatch, [port(4343)]).

:- use_module(library(pengines)).
:- use_module(pengine_sandbox:abr).
:- use_module(library(sandbox)).

:- multifile sandbox:safe_primitive/1.
sandbox:safe_primitive(abr:run(_,_,_)).

```

abr.pl:

```prolog
:- module(abr, [run/3]).

run(Cmd, ArgStr, Output) :-
    split_string(ArgStr, " ", "", Args),
    process_create(path(Cmd), Args, [stdout(pipe(OutStr)), stderr(pipe(OutStr))]),
    read_string(OutStr, _, Output),
    close(OutStr).

```

Query:

```prolog
?- pengine_rpc('http://localhost:4343', run(ls, "..", O)).

```

Is there a known limitation or something I can do to work around this? Anything needs to be closed explicitly?

Thanks a lot!  
Mike

---

<div class="post-metadata">

**Author:** ![firefrorefiddle](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/firefrorefiddle/32/4619_2.png) [@firefrorefiddle](https://swi-prolog.discourse.group/u/firefrorefiddle)\
**Post date:** [July 19, 2022, 7:55am UTC](https://swi-prolog.discourse.group/t/possible-bug-with-pengines-process-windows/5622/2 "2022-07-19T07:55:00Z")

</div>

Exact SWI version is `threaded, 64 bits, version 8.2.4`.
