[m-users.] Some POSIX support for Mercury
Volker Wysk
post at volker-wysk.de
Wed Sep 4 03:14:13 AEST 2024
Hi
There are just a handful of POSIX functions that are needed for creating
processes and building pipes and streams. With them, a predicate that runs a
specific program and connects to its stdin/stdout/stderr could be built. It
would also be possible to build pipes between processes and to redirect
stdin/stdout/stderr from/to files.
I think it wouldn't be hard to implement them in C (Unix and Windows) and
Java. I don't know any C#. An common Mercury abstraction of file descriptors
would be needed, that's shared between these three platforms.
The C version would just map them to the real POSIX calls (possibly with a
little more code for Windows). For Java, it can be done, too. Here's a file
descriptor class, which I've found on the web:
https://www.naukri.com/code360/library/file-descriptor-class-in-java
I've also found a project which aims at emulating POSIX in Java.
Unfortunately it's incomplete:
https://github.com/jnr/jnr-posix
And, there would also be needed a predicate which attaches a Mercury stream
to a file descriptor.
Cheers,
Volker
More information about the users
mailing list