J
Jan Stap
Hi,
I am writing a wrapper in C for an existing program. The wrapper
maintains a run file that is created for one invocation of the program
and is removed for another. My idea of making the last action
fool-proof is like this:
- save the run file status via stat()
- open the run file for reading
- unlink() it
- do an execv() on the program to be started
- if the execv() fails, restore the link to the inode saved by stat()
and close the run file
- otherwise, the run file is deleted upon completion of the program
started
However, link() only allows adding a link by referring to another link
to a given inode, not to the inode itself. Is there another way, or
should I forget about this scheme and just use a fork() to start the
program?
Thanks,
Jan Stap
I am writing a wrapper in C for an existing program. The wrapper
maintains a run file that is created for one invocation of the program
and is removed for another. My idea of making the last action
fool-proof is like this:
- save the run file status via stat()
- open the run file for reading
- unlink() it
- do an execv() on the program to be started
- if the execv() fails, restore the link to the inode saved by stat()
and close the run file
- otherwise, the run file is deleted upon completion of the program
started
However, link() only allows adding a link by referring to another link
to a given inode, not to the inode itself. Is there another way, or
should I forget about this scheme and just use a fork() to start the
program?
Thanks,
Jan Stap