1.5.16: DuplicateHandle(Out) failed (e=6)
Nathan L Mullen
nlm24@email.byu.edu
Fri May 27 07:14:00 GMT 2005
I recently upgraded from Cygwin 1.5.6-1 to 1.5.16-1.
I received the following error from GNU make 3.80 when I ran “mk” in Cygwin 1.5.16:
process_easy: DuplicateHandle(Out) failed (e=6)
t:/make/380/bin/make: interrupt/Exception caught (code = 0xc0000005, addr = 0x417344) system() returned code 65280: exit code 255
As both mk and make 3.80 are big (and don’t have a lot to do with Cygwin), I have spent some time narrowing down the problem. I have produced a set of small files that produce the same error. A very specific script structure is needed to reproduce the error (a bash script must call a perl script, which in turn must use back-ticks to run an executable that has a call to DuplicateHandle(Out)) (that is the same script structure that mk uses--and that causes DuplicateHandle(Out) to fail).
Here are the 3 necessary files to reproduce the error (showProb.sh, showProb.pl, showProb.c):
showProb.sh: ###########################################
#!/bin/sh
perl -S showProb.pl
showProb.pl: ##########################################
system("showProb.exe"); #this DupHandle works correctly
$cwd = `pwd`; # This completes successfully
system("showProb.exe"); #now DupHandle does _NOT_ work
showProb.c: ###########################################
/*
* Description: A very stripped-down version of process_easy in
* GNU make 3.80 (make/380/w32/subproc/sub_proc.c)
*/
#include <stdlib.h>
#include <stdio.h>
#include <process.h> /* for msvc _beginthreadex, _endthreadex */
#include <windows.h>
int main(){
HANDLE hOut;
if (DuplicateHandle(GetCurrentProcess(),
GetStdHandle(STD_OUTPUT_HANDLE),
GetCurrentProcess(),
&hOut,
0,
TRUE,
DUPLICATE_SAME_ACCESS) == FALSE) {
fprintf(stderr, "\nprocess_easy: DuplicateHandle(Out) failed (e=%d)\n", GetLastError());
/*return INVALID_HANDLE_VALUE;*/
}
else{
fprintf(stderr, "\nprocess_easy: DuplicateHandle(Out) SUCCESS\n");
}
CloseHandle(hOut);
return 0;
}
I used cl to compile showProb.c: “cl showProb.c –o showProb.exe”.
I have done some experimenting with the above scripts/code. The error is non-existent if the perl script or the executable is run alone (ie both DuplicateHandle calls complete successfully). Only when the perl script is called from the bash script does DuplicateHandle stop working after the `pwd` call.
This problem did not occur in 1.5.6-1. Is the system call in the back-ticks messing up the output handle in Cygwin 1.5.16? Why does it only happen if the perl script is called from a bash script? Is there something else happening?
Thanks for your time.
Nathan
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20050527/ea541850/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list