Closed Bug 46417 Opened 24 years ago Closed 24 years ago

PR_ProcessAttrSetStdioRedirect misbehaves

Categories

(NSPR :: NSPR, enhancement, P3)

Other
Solaris
enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: robm, Assigned: wtc)

Details

Attachments

(1 file)

I have a program I want to execute from a server program. I have a socket I want
to place on both standard input and standard output of the new program. I call:

PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, mysock);
PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, mysock);

This causes a failure after exec(), because the code in uxproces.c which
executes after the fork() but before the exec() does something like this:

if we need to dup onto stdin
  dup socket onto stdin
  close the socket
if we need to dup onto stdout
  dup socket onto stdout
  close the socket

So, if the same socket is used for both, the dup will fail. I think this code
needs to close the file descriptors only after all of the dup's have happened,
and it probably also needs to check for doubles.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → 4.1
Attached patch Proposed patch.Splinter Review
I came up with a patch as you suggested (close the file
descriptors after all the dup's have happened, and check
for doubles).  Please review and test it.  Thanks.
I checked in the patch on the main trunk.
/cvsroot/mozilla/nsprpub/pr/src/md/unix/uxproces.c, revision 3.13

Rob, I'd still appreciate it if you could review and test the
patch.  YThanks.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Thanks! I'll give it a try and let you know if it doesn't work. It looks like it
will work very well. 
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: