Mail Archives: cygwin/2013/08/08/09:29:39
X-Recipient: | archive-cygwin AT delorie DOT com
|
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
|
| :list-unsubscribe:list-subscribe:list-archive:list-post
|
| :list-help:sender:from:to:subject:date:message-id:mime-version
|
| :content-type; q=dns; s=default; b=d3pNt6rowiBkxXhMKzYtOXGp514jY
|
| 3so+vYqRU72rAxT4JLD/llSBcb35AfkHmg2rvJnK8RUfpaLAuRcwuiEbkb1HS1fN
|
| rYaAfcbm0CmiylMdH6+qwfLlsxteSVjR2hdtJ5Pfd5q5a/qmbVtrErxGmNKf91nZ
|
| jyYcQsYVO1wOcw=
|
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
|
| :list-unsubscribe:list-subscribe:list-archive:list-post
|
| :list-help:sender:from:to:subject:date:message-id:mime-version
|
| :content-type; s=default; bh=D+m0tsUQ5l3Bc89K0cK0J6TCNG4=; b=avx
|
| AsFLktsfwlfLKPqZOIIV85eR+KK+tV0EKefbrh85cuPffAiN6nAYfWdo/Kn4STrJ
|
| UjVnz5FLVFczJilIq0sDPe/lFpvvmA1GCazh3np1lNWLwhs4UbhnkwSk9w9hNVkR
|
| aemkBmrjMem7xnSmzQD+YWiRX/1xiScRHbI6UD4k=
|
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
|
X-Spam-SWARE-Status: | No, score=0.8 required=5.0 tests=AWL,BAYES_50,RCVD_VIA_APNIC,RDNS_NONE,SPF_HELO_PASS autolearn=no version=3.3.1
|
From: | Pavel Fedin <p DOT fedin AT samsung DOT com>
|
To: | cygwin AT cygwin DOT com
|
Subject: | [PATCH] Make - use spawn() instead of fork() - 3rd version
|
Date: | Thu, 08 Aug 2013 17:29:05 +0400
|
Message-id: | <001b01ce943b$41cdf100$c569d300$%fedin@samsung.com>
|
MIME-version: | 1.0
|
X-Virus-Found: | No
|
------=_NextPart_000_001C_01CE945C.C8DF9100
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hello!
My previous message apparently was lost, so i repeat in case if someone
would like to test it.
This is the latest version of the patch. It fixes problem with rebuilding
cygwin DLL, as well as follows some GNU Make maintainer recommendation
(extra security #ifndef). Please feel free to test and give feedbacks.
I would really love to see this accepted.
P.S. I tried to send this from my private email, but it did not get to any
recipient as it seems.
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia
------=_NextPart_000_001C_01CE945C.C8DF9100
Content-Type: application/octet-stream;
name="make-3.82.90-1-use-spawn-on-cygwin.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="make-3.82.90-1-use-spawn-on-cygwin.diff"
diff -ru make-3.82.90.orig/function.c make-3.82.90/function.c=0A=
--- make-3.82.90.orig/function.c 2011-12-02 20:35:49.000000000 +0400=0A=
+++ make-3.82.90/function.c 2013-08-06 18:34:59.154034700 +0500=0A=
@@ -1672,7 +1672,7 @@=0A=
return o;=0A=
}=0A=
=20=0A=
-# ifdef __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
/* close some handles that are unnecessary for the child process */=0A=
CLOSE_ON_EXEC(pipedes[1]);=0A=
CLOSE_ON_EXEC(pipedes[0]);=0A=
diff -ru make-3.82.90.orig/job.c make-3.82.90/job.c=0A=
--- make-3.82.90.orig/job.c 2011-12-02 20:35:49.000000000 +0400=0A=
+++ make-3.82.90/job.c 2013-08-07 17:23:42.033300500 +0500=0A=
@@ -111,8 +111,11 @@=0A=
# define WAIT_NOHANG 1=0A=
#endif /* WINDOWS32 */=0A=
=20=0A=
-#ifdef __EMX__=0A=
+#if defined (__EMX__) || defined (__CYGWIN__)=0A=
# include <process.h>=0A=
+# ifndef P_NOWAIT=0A=
+# define P_NOWAIT _P_NOWAIT=0A=
+# endif=0A=
#endif=0A=
=20=0A=
#if defined (HAVE_SYS_WAIT_H) || defined (HAVE_UNION_WAIT)=0A=
@@ -1351,7 +1354,7 @@=0A=
=20=0A=
parent_environ =3D environ;=0A=
=20=0A=
-# ifdef __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
/* If we aren't running a recursive command and we have a jobserver=
=0A=
pipe, close it before exec'ing. */=0A=
if (!(flags & COMMANDS_RECURSE) && job_fds[0] >=3D 0)=0A=
@@ -1365,6 +1368,7 @@=0A=
/* Never use fork()/exec() here! Use spawn() instead in exec_command=
() */=0A=
child->pid =3D child_execute_job (child->good_stdin ? 0 : bad_stdin,=
1,=0A=
argv, child->environment);=0A=
+ environ =3D parent_environ; /* Restore value child may have clobbere=
d. */=0A=
if (child->pid < 0)=0A=
{=0A=
/* spawn failed! */=0A=
@@ -2071,7 +2075,7 @@=0A=
#ifndef WINDOWS32=0A=
=20=0A=
/* EMX: Start a child process. This function returns the new pid. */=0A=
-# if defined __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
int=0A=
child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)=
=0A=
{=0A=
@@ -2158,7 +2162,7 @@=0A=
with environment ENVP. This function does not return. */=0A=
=20=0A=
/* EMX: This function returns the pid of the child process. */=0A=
-# ifdef __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
int=0A=
# else=0A=
void=0A=
@@ -2236,14 +2240,24 @@=0A=
=20=0A=
#else /* !WINDOWS32 */=0A=
=20=0A=
-# ifdef __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
int pid;=0A=
# endif=0A=
=20=0A=
/* Be the user, permanently. */=0A=
child_access ();=0A=
=20=0A=
-# ifdef __EMX__=0A=
+#ifndef __EMX__=0A=
+ /* CHECKME: This applies child's environment to ourselves making it poss=
ible=0A=
+ to locate the program in child's PATH which includes current directory=
=0A=
+ (our original PATH does not). Original EMX code didn't do this, howev=
er=0A=
+ on Cygwin this caused problems (inability to run perl script inside c=
urrent=0A=
+ build directory). This problem should affect EMX either, however unkn=
own=0A=
+ for sure. */=0A=
+ environ =3D envp;=0A=
+#endif=0A=
+=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
=20=0A=
/* Run the program. */=0A=
pid =3D spawnvpe (P_NOWAIT, argv[0], argv, envp);=0A=
@@ -2258,7 +2272,6 @@=0A=
# else=0A=
=20=0A=
/* Run the program. */=0A=
- environ =3D envp;=0A=
execvp (argv[0], argv);=0A=
=20=0A=
# endif /* !__EMX__ */=0A=
@@ -2318,7 +2331,7 @@=0A=
--argc;=0A=
}=0A=
=20=0A=
-# ifdef __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
pid =3D spawnvpe (P_NOWAIT, shell, new_argv, envp);=0A=
if (pid >=3D 0)=0A=
break;=0A=
@@ -2344,7 +2357,7 @@=0A=
break;=0A=
}=0A=
=20=0A=
-# ifdef __EMX__=0A=
+# if defined (__EMX__) || defined (__CYGWIN__)=0A=
return pid;=0A=
# else=0A=
_exit (127);=0A=
diff -ru make-3.82.90.orig/job.h make-3.82.90/job.h=0A=
--- make-3.82.90.orig/job.h 2010-07-13 06:20:41.000000000 +0500=0A=
+++ make-3.82.90/job.h 2013-05-17 14:56:12.818896600 +0500=0A=
@@ -77,14 +77,14 @@=0A=
int cmd_flags, char** batch_file);=0A=
#ifdef VMS=0A=
int child_execute_job (char *argv, struct child *child);=0A=
-#elif defined(__EMX__)=0A=
+#elif defined(__EMX__) || defined (__CYGWIN__)=0A=
int child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **en=
vp);=0A=
#else=0A=
void child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **e=
nvp);=0A=
#endif=0A=
#ifdef _AMIGA=0A=
void exec_command (char **argv);=0A=
-#elif defined(__EMX__)=0A=
+#elif defined(__EMX__) || defined (__CYGWIN__)=0A=
int exec_command (char **argv, char **envp);=0A=
#else=0A=
void exec_command (char **argv, char **envp);=0A=
diff -ru make-3.82.90.orig/main.c make-3.82.90/main.c=0A=
--- make-3.82.90.orig/main.c 2011-12-02 20:35:49.000000000 +0400=0A=
+++ make-3.82.90/main.c 2013-08-07 18:19:59.983579600 +0500=0A=
@@ -38,7 +38,7 @@=0A=
# include "sub_proc.h"=0A=
# include "w32err.h"=0A=
#endif=0A=
-#ifdef __EMX__=0A=
+#if defined (__EMX__) || defined (__CYGWIN__)=0A=
# include <sys/types.h>=0A=
# include <sys/wait.h>=0A=
#endif=0A=
@@ -2207,7 +2207,7 @@=0A=
#ifdef _AMIGA=0A=
exec_command (nargv);=0A=
exit (0);=0A=
-#elif defined (__EMX__)=0A=
+#elif defined (__EMX__) || defined(__CYGWIN__)=0A=
{=0A=
/* It is not possible to use execve() here because this=0A=
would cause the parent process to be terminated with=0A=
@@ -2216,15 +2216,15 @@=0A=
child process including all file handles and to wait for its=0A=
termination. */=0A=
int pid;=0A=
- int status;=0A=
+ int child_status;=0A=
pid =3D child_execute_job (0, 1, nargv, environ);=0A=
=20=0A=
/* is this loop really necessary? */=0A=
do {=0A=
- pid =3D wait (&status);=0A=
+ pid =3D wait (&child_status);=0A=
} while (pid <=3D 0);=0A=
/* use the exit code of the child process */=0A=
- exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);=0A=
+ exit (WIFEXITED(child_status) ? WEXITSTATUS(child_status) : EXIT_FAIL=
URE);=0A=
}=0A=
#else=0A=
exec_command (nargv, environ);=0A=
------=_NextPart_000_001C_01CE945C.C8DF9100
Content-Type: text/plain; charset=us-ascii
--
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
------=_NextPart_000_001C_01CE945C.C8DF9100--
- Raw text -