r/ATS • • Sep 30 '20

[question] Any functions/facilities for spawning subprocesses?

Hello!
Newbie question here: are there existing functions/facilities/libraries for spawning a subprocess and reading its exit code and stdout?

Similar to the subprocess lib from Python:

https://docs.python.org/3/library/subprocess.html

4 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/thalesmg Oct 02 '20

Awesome! Thanks for all the references!! I'll have a look and try it out. 🍻

2

u/avanov Oct 02 '20

no problem! Another approach would be to reuse an existing higher-level C interface and to wrap it with ATS definitions (outlined on the same wiki page), as @doublec suggested. To name one, here's https://github.com/sheredom/subprocess.h and you can see that it calls the same fork & execve/execvp under the hood: https://github.com/sheredom/subprocess.h/blob/master/subprocess.h#L591-L601