I would like to suggest solving the
problem without the use of quoting:
#include <spawn.h>
char ** argv = { "rm", "-Rf", Sys_TempDir, NULL };
posix_spawnp(NULL, "rm", NULL, NULL, argv, NULL);
Are there Unix-like platforms on which R is intended to work that don't
have posix_spawn()? Circa-2014 versions of both Solaris and OpenBSD
seem to have it. Spawning the process manually by means of [v]fork()
and exec() is probably not worth the maintainer effort required to
perform it correctly.
Yes, this is a good point and we have been thinking about spawn() as
well, and we are considering that. Re implementing, I also fear the
cost may be too high, thinking about the timeout support in system() I
implemented earlier, so essentially a system() replacement for Unix.
The details are complicated on Unix as well as on Windows. And re
reusing existing implementations, we will have to check they do
exactly what we need about signals, terminal, process groups,
termination, input and output, etc. It may also be that improving
performance of R_unlink() would be easier, as it is rather
un-optimized now. So I just wanted to buy time with (possibly
temporary) fix in 83851.
Thanks
Tomas