Closed Bug 128798 Opened 23 years ago Closed 3 years ago

Use of FILE_FLAG_OVERLAPPED in ntio.c for _PR_MD_OPEN causes stdio redirect problems

Categories

(NSPR :: NSPR, defect)

4.1.1
x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: mike, Unassigned)

Details

I want to redirect process output/error to a file. I use the following sequence (loosely) PR_OpenFile (as writable) PR_SetFDInheritable (using handle from open above) PR_NewProcessAttr PR_SetStdioRedirect (using same handle and new process attr struct) PR_CreateProcess (using process attr struct) The file is created and the process runs. However any writes to the file don't work and nothing ends up in the file. The problem seems to be with the use of the FILE_FLAG_OVERLAPPED flag when opening files on Windows NT (see ntio.c around line 2086). If this flag is not used then the writes in the child process end up in the file and everything is fine. The problem is how to prevent the use of FILE_FLAG_OVERLAPPED when the file is a target of a stdio redirection.
Thanks for the bug report. This is a known problem. I didn't come up with a solution when I worked on this. One workaround is to use the "WIN95" version of NSPR. You build the "WIN95" version by passing OS_TARGET=WIN95 to gmake. The only solution I can come up with is to add a new flag to PR_Open and PR_OpenFile that says this file descriptor will be inheritable. On Windows, the FILE_FLAG_OVERLAPPED flag must be passed to CreateFile() at file open time, and can't be changed later. So the NSPR API will be subject to these constraints.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
QA Contact: wtchang → nspr

The bug assignee didn't login in Bugzilla in the last 7 months.
:KaiE, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: wtc → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(kaie)

(In reply to Wan-Teh Chang from comment #1)

One workaround is to use the "WIN95" version of NSPR.

That seems to be the default nowadays, so no further action seems necessary.

Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(kaie)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.