Is there a way to run command line utilities, e.g. gzip
, into a C app?
When you hit Ctrl + c , the line discipline of your terminal sends SIGINT to processes in the foreground process group. Bash, when job control is disabled, runs everything in the same process group as the bash process itself. Job control is disabled by default when Bash interprets a script.
Use system()
:
#include <stdlib.h>
int status = system("gzip foo");
See the man page (man 3 system
) for more detailed information on how to use it.
By the way, this question already has an answer here: How do I execute external program within C code in linux with arguments?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With