open file descriptor in remote process

This is a discussion on open file descriptor in remote process within the Linux Programming forums, part of the Platform Specific Boards category; Is it possible to open up a file descriptor in my program. And then pass it to a child process ...

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,534

    open file descriptor in remote process

    Is it possible to open up a file descriptor in my program. And then pass it to a child process for use (along with permissions)? I know each process has it's own list of descriptors, so I don't know how this would be done.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    yes. This is common. What many programs do is to open some file to which they need access and then chroot and change userID (to a lesser user) to do processing. This is for security's sake.

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,160
    File descriptors remain valid after a call to fork(). Normally, they also remain valid after a call to exec(), unless the FD_CLOEXEC flag is set of that descriptor.

    So the answer is yes.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,534
    Great. Thanks.
    I didn't know exec() did that.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequenceing or queueing multiple process
    By sv_joshi_pune in forum Windows Programming
    Replies: 1
    Last Post: 08-14-2009, 09:43 AM
  2. Replies: 3
    Last Post: 02-19-2009, 11:46 PM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 12:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21