Find the answer to your Linux question:
Results 1 to 6 of 6
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    fexec()?


    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.

  2. #2
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    file descriptor

    Dolda,

    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.
    The best things in life are free.

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That was precisely what I would like to do, but I haven't found a way of doing it, which I think seems strange.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Code:
    #include <fcntl.h>
    int fd;
    
    fd = open&#40; "file", O_RDONLY &#41;;
    ...
    /* set close on exec flag ON */
    fcntl&#40; fd. F_SETFD, 1 &#41;;
    
    /* OR set close on exec flag OFF */
    fcntl&#40; fd, F_GETFD, 0 &#41;;
    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.
    The best things in life are free.

  6. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    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!

  7. #6
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    well

    Dolda,

    Keep trying. The answer is bound to come up somewhere. Sorry that I couldn't have been more helpful.
    The best things in life are free.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •