Does someone know if there is a syscall somewhere that I haven't seen or that is undocumented or so that allows you to exec an open file (as opposed to a file name). It seems peculiar to me that there are fchmod, fchown, ftruncate, etc. while there is no fexec. And no flink, for that part.
I'm not sure if this would be helpful but I'm thinking that you can open a file and get the file descriptor then passing that onto exec. Then again, this sounds too easy so you probably already thought of this.
That was precisely what I would like to do, but I haven't found a way of doing it, which I think seems strange.
Again, I'm not too sure if this is what you are looking for but that's the best example the book provides on exec with files.
fd = open( "file", O_RDONLY );
/* set close on exec flag ON */
fcntl( fd. F_SETFD, 1 );
/* OR set close on exec flag OFF */
fcntl( fd, F_GETFD, 0 );
No, that's not it. The close-on-exec flag indicates whether or not the file descriptor should be automatically closed (by the kernel) when exec is called.
Thank you for looking so hard to help me, though!
Keep trying. The answer is bound to come up somewhere. Sorry that I couldn't have been more helpful.