Thread: open file descriptor in remote process

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

    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.

  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
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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
    2,158
    Great. Thanks.
    I didn't know exec() did that.

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-20-2009, 12:46 AM
  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