Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:42:53+00:00 2026-05-27T01:42:53+00:00

What are the portable options if one needs to export open file descriptors to

  • 0

What are the portable options if one needs to export open file descriptors to child processes created using exec family of library functions?

Thank you.

EDIT. I know that child processes inherit open descriptors. But how they use those descriptors without knowing their values? Should I implement some sort of IPC in order to pass descriptors to the child process? For example, if the parent creates a pipe, how can an execed child process know read/write ends of the pipe?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:42:54+00:00Added an answer on May 27, 2026 at 1:42 am

    Simply don’t set the O_CLOEXEC open(2) flag or its corresponding (and standard) FD_CLOEXEC fcntl(2) flag on the descriptor — it’ll be passed across an exec*() by default.

    Update

    Thanks for the clarification, that does change things a little bit.

    There are several possibilities:

    • Use command line arguments: GnuPG in gpg(1) provides command line switches --status-fd, --logger-fd, --attribute-fd, --passphrase-fd, --command-fd for each file descriptor that it expects to receive. If there are several kinds of data to submit or retrieve, this lets each file descriptor focus on one type of data and reduces the need for parsing more complicated output.

    • Just work with files and accept filenames as parameters; when you call the program, pass it file names such as /dev/fd/5, and arrange for the input to be on fd 5 before calling the program:

      cat /dev/fd/5 5</etc/passwd
      
    • Follow conventions: supply 0 to the child as the read end of a pipe, 1 to the write end of a pipe, and let it work as a normal pipeline “filter” command. This is definitely the best approach if all the input can be reasonably sent through a single file descriptor — not always desirable.

    • Use an environment variable to indicate the file / socket / fd:

      SSH_AUTH_SOCK=/tmp/ssh-ZriaCoWL2248/agent.2248
      DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-CsUrnHGmKa,guid=e213e2...
      

      This is nice to pass the file information through many child programs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A portable thread specific storage reference/identity mechanism, of which boost/thread/tss.hpp is an instance, needs
I need a portable C/C++ solution, so I'm looking for a C/C++ client library
I have a Portable Bridge Notation formatted-file that I have to work with. I
What is the accepted, portable way to include interpreter options in the shebang line,
The change target framework dialog in the portable class library properties has a link
We are producing a portable code (win+macOs) and we are looking at how to
Is there a portable, not patent-restricted way to play compressed sound files in C#
Is there a portable way of getting thread and/or process identifier (string, int, ...)
Is the following code portable? template<typename In> struct input_sequence_range : public pair<In,In> { input_sequence_range(In
I installed portable python on my USB drive, and I really like pyscripter a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.