I want to fork and exec a binary in c. The parameter for calling the binary contains a space, see first line of sample code. If execute my binary with `plist [2] = conPtr -> conmon_cmd[f];` the parameter is not evaluated correctly.
Using the two commented line will bring me the result which I desire. How can I escape the space in the first line of the code snippet so that I have only one plist parameter for the arguments?
conPtr->conmon_cmd = "clear_config all";
[...]
printf("child process started (PID = %i)\n", pid);
char *plist[6];
plist [0] = "/tmp/conmon_audinate_controller";
plist [1] = "localhost";
plist [2] = conPtr -> conmon_cmd;
//plist [2] = "clear_config";
//plist [3] = "all";
plist [4] = (char *)NULL;
char *file = "conmon_audinate_controller";
execvp (file, plist );
Info: the conmon_audinate_controller is an external executable. In the bash on my ucLinux the call would be like:
/tmp # ./conmon_audinate_controller localhost clear_config all