Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: From: Steve Fairbairn To: "'cygwin AT cygwin DOT com'" Subject: Problem with Cygwin DLL: 1003.15.0.0 & 1003.16.0.0 Date: Mon, 25 Nov 2002 13:06:33 -0000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C29483.7A9F1DB0" Note-from-DJ: This may be spam ------_=_NextPart_000_01C29483.7A9F1DB0 Content-Type: text/plain; charset="iso-8859-1" Hi, I have come across a problem with cygwin which relates to the Windows CreateProcess() function. Tested on Cygwin DLLs: 1003.15.0.0 & 1003.16.0.0 Windows 2000 sp3 I have a Visual C++ program which uses CreateProcess to launch an executable much like the example provided in the attachment. The example has been hard coded to execute a cygwin compiled binary (ls) as this is what I was attempting to do in the real thing. When the program is run from a dos command prompt, it all works perfectly. However when the program is run from cygwin bash, the launched program (ls) fails with a read exception somewhere in the cygwin dll. If the program is changed to execute a non cygwin-built binary, it all seems to work fine. I also bring your attention to the following lines from the example... /* Something to do with bInheritHandles being FALSE, as when it is TRUE, it works. */ CreateProcess(0, cmd, 0, 0, FALSE, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS, 0, cwd, &StartupInfo, &ProcessInformation); When the CreateProcess call is changed so handles are inherited, it all works perfectly. If this is the wrong place to report an issue like this, then please let me know where I should email instead. I couldn't spot any other likely candidates. Regards, Steve Fairbairn. <> PS. Full VC++ Workspace and binaries are available, I just didn't want to attach it on a mail to the whole list. PPS. Apologies for the disclaimer, nothing I can do to stop it :(. ******************************************************* This email has originated from Perwill plc (Registration No. 1906964) Office registered at: 13A Market Square, Alton, Hampshire, GU34 1UR, UK Tel: +44 (0)1420 545000 Fax: +44 (0)1420 545001 www.perwill.com ******************************************************* Privileged, confidential and/or copyright information may be contained in this email, and is only for the use of the intended addressee. To copy, forward, disclose or otherwise use it in any way if you are not the intended recipient or responsible for delivering to him/her is prohibited. If you receive this email by mistake, please advise the sender immediately, by using the reply facility in your email software. We may monitor the content of emails sent and received via our network for the purposes of ensuring compliance with policies and procedures. This message is subject to and does not create or vary any contractual relationships between Perwill plc and the recipient. ******************************************************* Any opinions expressed in the email are those of the sender and not necessarily of Perwill plc. ******************************************************* This email has been scanned for known viruses using McAfee WebShield 4.5 MR1a ******************************************************* ------_=_NextPart_000_01C29483.7A9F1DB0 Content-Type: application/octet-stream; name="test.c" Content-Disposition: attachment; filename="test.c" #include #include #include long win32_execute_binary(char *cwd, char *cmd, char *envp[]) { HANDLE hndl, opfp=0; int i,r,append2file=0; STARTUPINFO StartupInfo={0}; PROCESS_INFORMATION ProcessInformation={0}; GetStartupInfo(&StartupInfo); StartupInfo.dwFlags = STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; StartupInfo.cb = sizeof(STARTUPINFO); /* add new ENV variables - not thread safe tho. */ for (i=0;envp && envp[i];i++) { _putenv(envp[i]); } /* Something to do with bInheritHandles being FALSE, as when it is TRUE, it works. */ CreateProcess(0, cmd, 0, 0, FALSE, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS, 0, cwd, &StartupInfo, &ProcessInformation); hndl = ProcessInformation.hProcess; if (!hndl) r = GetLastError(); /* wait for it to finish */ { DWORD w; w= WaitForSingleObject(hndl, INFINITE); if (w == WAIT_FAILED) r = GetLastError(); } // handles must be closed as not used if (ProcessInformation.hProcess) CloseHandle(ProcessInformation.hProcess); if (ProcessInformation.hThread) CloseHandle(ProcessInformation.hThread); return (long)hndl; } int main(int arc, char *argv[], char *envp[]) { long ret = 0; ret = win32_execute_binary("/home/Administrator", "ls", envp); printf("Return val = %ld\n", ret); exit(0); } ------_=_NextPart_000_01C29483.7A9F1DB0 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ------_=_NextPart_000_01C29483.7A9F1DB0--