Vala: why is `system()` unavailable in Windows?

system() in C exists in both Win32 and Posix, but it’s only available in Posix VAPI. Is there any special reason for this?

Also, Is it necessary to encapsulate the parts that both Win32 API and Unix API can implement in a new VAPI?

Hi!

Here’s an explanation from an historical perspective as to why there’s no cstdlib vapi: vala - Where are the VAPI for the C standard library? - Stack Overflow

The system() API was added in POSIX.vapi with commit https://gitlab.gnome.org/GNOME/vala/-/commit/dcad683f43

glib-2.0.vapi has no direct wrapper for the system() function, but maybe you could use the g_spawn functions?

Nobody in their right mind should use system() in 2022.

GLib has g_spawn_* and GIO has GSubprocess.

3 Likes