On 8/3/2021 1:03 PM, Norman Gray wrote:
On 3 Aug 2021, at 17:38, George Neuner wrote:
Racket is multi-platform and tries to present a common API for
dealing with underlying operating systems. Windows is an important
platform, but Windows does not have the concept of fork/exec ... so
Racket doesn't offer it either.
Ah: good point. That said, I'd have guessed that similar behaviour --
'invoke and don't return' -- would be at least emulatable on Windows,
though.
Well, yes, but the behavior of 'CreateProcess' is quite different from
the combination of 'forkv/execv'.
In Windows, the new child is not (even virtually) a copy of its parent -
it is a completely new process context. Although it is possible for the
parent to pass to and/or share resources with the child, this doesn't
include a copy of its memory context [so no 'fork']. The parent
receives several handles to the new child process that must explicitly
be closed in order to detach it.
As a technical matter, emulating Unix 'fork' in Windows ... i.e. making
an independent copy of the parent process that continues running from
where the parent stopped ... is possible, but it is difficult and
requires debugger like behavior to manipulate the child's memory map and
copy data from one process to the other.
The closest (and simplest) you can achieve, I think, would to start
Vi asynchronously using 'process*' and then terminate the Racket script.
I don't think that works, since terminating the Racket process would
also terminate its child (unless I were to do something similar to the
usual extra fork to disconnect the child from its parent, and... hmmm,
this isn't sounding very rackety).
Doing the next simplest thing -- using (process* "/usr/bin/vi"
'("foo")) and calling (control 'wait) using the result -- doesn't seem
to work, but instead just hangs, until I kill the vi child process.
Without digging into it too deeply, I'd guess that's because of the
usual problems about wiring up FDs and buffers and so on, which I was
rather hoping to avoid.
Hmm. According to the docs 'process' (no asterisk) executes the
command asynchronously ... I assumed 'process*' would do the same.
Unfortunately 'process' returns ports that must be closed explicitly.
Sorry if I led you astray.
Best wishes,
Norman
George
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/720fc753-7972-b8c1-76ec-4d2a65a763f2%40comcast.net.