I am having a bit of trouble using gzip to compress a file from a C program. I am using this line of code execl("/usr/bin/gzip", "-f", filePath, NULL);
to compress the file given by filePath
. It works fine the first time (i.e. when there is no existing .gz file), but in subsequent executions of the program I am prompted whether or not I would like to overwrite the existing .gz file.
Am I using execl()
incorrectly, because I am pretty sure that the -f
switch forces gzip to overwrite without a prompt?