I need to write to an executable file that is being executed, but I can't open it for writing. For example:
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd = open(argv[0], O_RDWR);
if (fd == -1) perror(NULL);
return 0;
}
% uname -rs FreeBSD 8.0-STABLE % ./example_ETXTBSY Text file busy
There are some explanations what the heck is ETXTBSY in Linux, but nevertheless, is it possible to override this error?
P.S.
I'm not trying to write a virus.