Subject: Re: Patch: Bug: Shell fork/exec avoidance in make-3.79.1-3
From: Earl Chew <[email-masked]>
To: Bernard Dautrevaux <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Tue, 26 Jun 2001 12:40:37 -0700

Bernard Dautrevaux wrote:
> Earl Chew wrote:
> > I've included a patch below that changes all the char[] definitions
> > in job.c to char*.
> 
> I don't think that is the problem; if I look at your patch below, the
> char[] definitions you change in char* are only used on AMIGA or VMS,
> but *NOT* on CYGWIN... ;-(

I don't think that's true.

I've changed three instances of char default_shell[] to
char* default_shell.

1. Pertains to AMIGA
2. Pertains to VMS
3. Pertains to those cases not covered above (ie includes Cygwin)

> If you look at my previous message (posted about in paralell with
> your), you'll see that just recompiling the code without any change
> allow me to get a working make.

I recompile make-3.79.1-3 without making any changes and observed
the incorrect behaviour --- and from that incorrect behaviour
figured out what the problem was.

> IMHO it's just the cygwin package that was compiled in a
> buggy environment.

I don't think so. Here's some analysis:

a. In main.c

   extern char* default_shell;

b. In job.c

   There are exactly five definitions of default_shell:

	1. WINDOWS32:	char* default_shell = "sh.exe"
	2. AMIGA:	char default_shell[] = ""
	3. MSDOS:	char* default_shell = "command.com"
	4. VMS:		char default_shell[] = ""
	5. else:	char default_shell[] = "/bin/sh"

   The only definitions that might be applicable to Cygwin are
   [1] (WINDOWS32) or [5] (else).

   I'm pretty sure the WINDOWS32 case is out of the question
   because you can find lots of Win32 specific code in main.c
   that kicks in if you define this (eg #include <windows.h> ;-).

   That leaves [5] --- which results in a char[] definition which
   does not match the extern char* declaration in main.c :-(

Earl
-- 
> ---------------------------------------------------------------------+
> Earl Chew                              http://www.agilent.com        |
> Agilent Technologies                   mailto:[email-masked]  |
> Advanced Networks Division             Tel:   +1 604 454 3411        |
> 2500-4710 Kingsway                     Fax:   +1 604 454 3401        |
> Burnaby BC V5H 4M2 Canada                                            |
> ---------------------------------------------------------------------+
--- job.c.orig  Sun Mar 11 12:45:49 2001
+++ job.c       Tue Jun 26 10:29:58 2001
@@ -40,7 +40,7 @@
 int batch_mode_shell = 1;
 #else  /* WINDOWS32 */
 # ifdef _AMIGA
-char default_shell[] = "";
+char* default_shell = "";
 extern int MyExecute (char **);
 # else /* _AMIGA */
 #  ifdef __MSDOS__
@@ -52,9 +52,9 @@
 #  else  /* __MSDOS__ */
 #   ifdef VMS
 #    include <descrip.h>
-char default_shell[] = "";
+char* default_shell = "";
 #   else
-char default_shell[] = "/bin/sh";
+char* default_shell = "/bin/sh";
 #   endif /* VMS */
 #  endif /* __MSDOS__ */
 int batch_mode_shell = 0;

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