From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27144 invoked by alias); 20 Oct 2011 08:22:14 -0000 Received: (qmail 27127 invoked by uid 22791); 20 Oct 2011 08:22:09 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from vpn.ubitronix.com (HELO mail.ubitronix.com) (194.187.178.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 Oct 2011 08:21:51 +0000 Received: from ex01-ubitronix.ubitronix.local ([10.1.10.11]) by ex01-ubitronix.ubitronix.local ([10.1.10.11]) with mapi; Thu, 20 Oct 2011 10:19:52 +0200 From: Manuel Wienand To: "cygwin@cygwin.com" Date: Thu, 20 Oct 2011 08:22:00 -0000 Subject: 1.7.9: spawn brakes reopening of serial port Message-ID: <0C11C5BF0B29FD43A8D0250F711D497F89DEDBFEE2@ex01-ubitronix.ubitronix.local> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-10/txt/msg00383.txt.bz2 Hallo, it seems that spawning a process brakes the reopening of a serial port (whe= n done during the execution of that process). The result of the open() func= tion is "Permission denied (13)" in that case. How to test: Run the following code ;) TestSharedMemProc is the process that should be spawned by TestSharedMem (y= es, the name is misleading, but it's just a test...). First I had shm_open under investigation for my problem, because sometimes = I got a "Bad Address" (EFAULT, 14) error, but I couldn't reproduce it with = a small program and I'm not sure if the problem is somehow connected to the= serial port problem. In my original program I got it when opening the shar= ed memory in the spawned (child) process. The shared memory was created in = the parent process first and did exist in /dev/shm. shm_open() returning EFAULT seems to be cygwin specific; what could have ca= used it? Maybe with a hint in the right direction I might be able to reprod= uce the error as well. Thanks, Manuel /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Name : TestSharedMem.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D */ #include #include #include #include #include #include #include #define COMPORT_NAME "/dev/com1" #define SPAWN_FILE_NAME "./TestSharedMemProc.exe" int serialportHandle =3D -1; int SC_Close() { if( serialportHandle >=3D 0 ) { fprintf(stdout, "Closing handle %d.\n", serialportHandle); if( close(serialportHandle) < 0 ) { fprintf(stdout, "Couldn't close COM-Port: %s :%d \n",sys_errlist[errn= o],errno); return 3; } } serialportHandle =3D -1; return 0; } int SC_Open() { // Close any already open connections first if( serialportHandle >=3D 0) { fprintf(stdout, "Open called before closing the port. Closing the port = now.\n"); SC_Close(); } // Call open to open a port serialportHandle =3D open(COMPORT_NAME, O_RDWR | O_NONBLOCK ); if( serialportHandle < 0 ) { fprintf(stdout, "Couldn't open COM-Port (%s): %s :%d \n",COMPORT_NAME,s= ys_errlist[errno],errno); return 4; } fprintf(stdout, "Opened port %s (handle %d).\n", COMPORT_NAME, serialport= Handle); return 0; } int main(void) { puts("TestSharedMem"); int error; error =3D SC_Open(); if (error !=3D 0) { printf("first open(COM port %s) failed.\n", COMPORT_NAME); } // Spawn //int pid =3D spawnl(_P_WAIT, SPAWN_FILE_NAME, "TestSharedMemProc", NULL); int pid =3D spawnl(_P_NOWAITO, SPAWN_FILE_NAME, "TestSharedMemProc", NULL= ); if (pid =3D=3D -1) { printf( "Failed to create process: %s %d\n", sys_errlist[errno],errno); } //sleep(2); // If the process closes before the next SC_Open, it works. error =3D SC_Open(); if (error !=3D 0) { printf("second open(COM port %s) failed.\n", COMPORT_NAME); } SC_Close(); puts("Done (TestSharedMem)."); return EXIT_SUCCESS; } /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Name : TestSharedMemProc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D */ #include #include #include int main(void) { puts("TestSharedMemProc"); sleep(1); // This process must be running when // opening the COM port the second time // -> maybe you need to increase the time puts("Done (TestSharedMemProc)."); return 0; } -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple