delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/04/02/10:21:36

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.0 required=5.0 tests=BAYES_00,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_SORBS_WEB,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <49D4D802.8040005@pocock.com.au>
Date: Thu, 02 Apr 2009 16:21:38 +0100
From: Daniel Pocock <daniel AT pocock DOT com DOT au>
User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: execve issues, and execve with cygrunsrv
References: <49D0B0CD DOT 6050009 AT pocock DOT com DOT au> <20090331112427 DOT GC12738 AT calimero DOT vinschen DOT de>
In-Reply-To: <20090331112427.GC12738@calimero.vinschen.de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Corinna Vinschen wrote:
> On Mar 30 12:45, Daniel Pocock wrote:
>   
>> Hi,
>>
>> I'm using the execve call in a UNIX program (which works successfully),
>> and now I am testing it with Cygwin.
>>
>> The program is using execve as a way to restart itself after receiving
>> SIGHUP.
>>
>> The child process started by execve seems to be unable to work properly,
>> I observe various errors:
>> - DNS lookups fail
>> - binding to UDP sockets fails
>>     
>
> Is that with Cygwin 1.5.25 or with Cygwin 1.7?  If it's 1.5.25, could
> you try if this still occurs under Cygwin 1.7?
>   
I tried with both.

On 1.5.25, execve works, but the new process can't open sockets

On 1.7, the socket problem is gone, but there are other issues with 
cygrunsrv

> Does this only happen when started from a native Windows process (cmd.exe
> or so) or does this also happen when started from Cygwin's bash?
>
>   
Tested from Cygwin's bash, and as a service under cygrunsrv
>> Furthermore, I would like the process to become a service started by
>> cygrunsrv.  Is it safe to use execve in a process started by cygrunsrv?
>>     
>
> Did you try?
>   
I have now had a chance to try it under cygrunsrv from Cygwin 1.5.25 and 1.7

Under 1.5.25, it doesn't work because of the sockets issue

Under 1.7, a new issue is revealed: execve doesn't maintain the same 
process ID, so cygrunsrv thinks the service has actually stopped, and 
the cygrunsrv process exits.  This is obviously quite bad.

I tried to work around it by creating a PID file, and passing the -x 
parameter to cygrunsrv.  It seems that cygrunsrv only checks the PID 
file when first started, and not after execve.  A possible workaround 
would be for cygrunsrv to check for a new PID file each time the process 
exits.

This brings me to a few more questions:

- Can execve be implemented on Cygwin in such a way that the PID is 
preserved?  This would be the best solution for portability.

- Can cygrunsrv be enhanced to deal with this behaviour?



--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019