delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/06/03:19:27

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Date: Fri, 6 Jun 2003 09:19:07 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Slight patch for Cron
Message-ID: <20030606071907.GA12547@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20030604144829 DOT GU875 AT cygbert DOT vinschen DOT de> <Pine DOT LNX DOT 4 DOT 44 DOT 0306051030410 DOT 15479-100000 AT localhost DOT localdomain>
Mime-Version: 1.0
In-Reply-To: <Pine.LNX.4.44.0306051030410.15479-100000@localhost.localdomain>
User-Agent: Mutt/1.4.1i

On Thu, Jun 05, 2003 at 01:01:19PM +0200, Ronald Landheer-Cieslak wrote:
> On Wed, 4 Jun 2003, Corinna Vinschen wrote:
> > On Wed, Jun 04, 2003 at 09:53:05AM +0200, Ronald Landheer-Cieslak wrote:
> > > On Tue, 3 Jun 2003, Corinna Vinschen wrote:
> > > > Does it help to set CYGWIN=notty before starting cron?
> > > Apparently not, no.
> > > 
> > > Because I'm starting cron from the "startup" part of the start menu, I had 
> > > to run it from a batch file (
> > > set CYGWIN=notty
> > > cron.exe
> > > ) but I don't think that should make a difference.
> > Could you just for fun add a call to RegisterServiceProcess() (that
> > works on 9x/Me only) right before the setsid() call in the child code
> > and try again?
> I'd love to, but I have a Windows NT/4 box and thus don't have 
> RegisterServiceProcess() (Windows NT Ver 4.0 Build 1381 Service Pack 6, as 
> per cygcheck output attached to a previous message).

As it seems to turn out, it's a problem in cron, not in Cygwin.  What
you see is not the parent not being able to exit, it's the child which
has open console descriptors and so keeping the console open.  If you
then try to close the console forcefully, you kill the child.

Please apply the following patch to cron and report back whether cron
does for you what it's supposed to do (parent leaves, window can be
closed, cron still processes files), or not.

Your positive feedback will trigger a new cron version asap :-)

Thanks,
Corinna

Index: cron.c
===================================================================
RCS file: /home/cvs/cvsroot/src/cron/cron.c,v
retrieving revision 1.5
diff -p -u -r1.5 cron.c
--- cron.c	11 Apr 2003 19:42:37 -0000	1.5
+++ cron.c	6 Jun 2003 07:13:17 -0000
@@ -26,6 +26,7 @@ static const char rcsid[] = "$Id: cron.c
 #include "cron.h"
 #ifdef __CYGWIN__
 #include <signal.h>
+#include <sys/fcntl.h>
 #else
 #include <sys/signal.h>
 #endif
@@ -115,6 +116,21 @@ main(argc, argv)
 	}
 
 	acquire_daemonlock(0);
+
+#ifdef __CYGWIN__
+	{
+	  int fd;
+	  if ((fd = open("/dev/null", O_RDWR, 0)) != -1)
+	    {
+	      (void)dup2(fd, STDIN_FILENO);
+	      (void)dup2(fd, STDOUT_FILENO);
+	      (void)dup2(fd, STDERR_FILENO);
+	      if (fd > 2)
+		(void)close (fd);
+	    }
+	}
+#endif
+
 	database.head = NULL;
 	database.tail = NULL;
 	database.mtime = (time_t) 0;

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

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