delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/01/09/05:47: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, 9 Jan 2004 11:41:57 +0100 (CET)
From: <mbuch AT IFF572 DOT IFF DOT KFA-JUELICH DOT DE>
Reply-To: m DOT buchmeier AT fz-juelich DOT de
To: cygwin AT cygwin DOT com
Subject: Re: an old problem with cygwin (fwd)
Message-ID: <Pine.LNX.4.21.0401091141330.11350-100000@IFF572.IFF.KFA-JUELICH.DE>
MIME-Version: 1.0
X-Spam-Status: No, hits=-99.5 required=5.0 tests=NO_REAL_NAME,USER_IN_WHITELIST version=2.31
X-Spam-Level:

> Date: Thu, 08 Jan 2004 17:11:32 +0100 (MET)
> From: tekz AT gmx DOT de
> To: m DOT buchmeier AT fz-juelich DOT de
> Subject: an old problem with cygwin
> 
> On "http://www.cygwin.com/ml/cygwin/2001-11/msg00254.html" you reported
> problems about running a cygwin bound program outside an "unix" shell:
> 
> > system() function doesnt work outside cygwin
> 
> So my answer is: It does work!
> But there are some conditions to provide the expected functionality:
> 
> You use the "C" function "system( .. )" to execute an external (shell)
> command.
> The following statements are true:
> a) the function is included through "<stdlib.h>"
> b) the function is part of "libc"
> c) the file "system.c" can be found in the "cygwin-libc" source tree
> d) the following function will be executed by a call to "system( .. )":
> 
> <code>
> static int
> do_system (ptr, s)
>      struct _reent *ptr;
>      _CONST char *s;
> {
>   char *argv[4];
>   int pid, status;
> 
>   argv[0] = "sh";
>   argv[1] = "-c";
>   argv[2] = (char *) s;
>   argv[3] = NULL;
> 
>   if ((pid = vfork ()) == 0)
>     {
>       /* ??? It's not clear what's the right path to take (pun intended :-).
> 	 There won't be an "sh" in any fixed location so we need each user
> 	 to be able to say where to find "sh".  That suggests using an
> 	 environment variable, but after a few more such situations we may
> 	 have too many of them.  */
>       char *sh = getenv ("SH_PATH");
>       if (sh == NULL)
> 	sh = "/bin/sh";
>       _execve (sh, argv, environ);
>       exit (100);
>     }
>   else if (pid == -1)
>     return -1;
>   else
>     {
>       int rc = _wait (&status);
>       if (rc == -1)
> 	return -1;
>       status = (status >> 8) & 0xff;
>       return status;
>     }
> }
> </code>
> 
> e) the function above executes the (shell) command through "sh"
> 
> conclusion: if you are trying to execute an external command from your
> cygwin bound program through
> a call to function "system( .. )" and the program "sh" ( "sh.exe" ) is not
> provided or can't be found in your standard windows search path than your
> program will and has to fail.
> 
> 
> thank you for reading this!
> One question arises: why does nobody explain this in the mailing list, news
> group or web ??
> 
> So, finally, my question to you is: did anybody help you by explaining
> something like this ??

My answer is no, noone was able to explain that i need the sh.exe
programm in my path. I also was not able find this info in the
documentation.
Finally David Mathog (mathog AT caltech DOT edu) running into the same 
problem came to the conclusion that this behavior should be a bug, 
however i think there aws no reponse from the cygwin developpers 
and i didnt find the time to dig into the sources.

thankx for your explanation, i will try the solution out. 

				Matthias Buchmeier
				
###############################################
#         mail:  Matthias Buchmeier           #
#                IFF-IEE (Gruppe Gr"unberg)   #
#                Forschungszentrum J"ulich    #
#                52425 Juelich                #
#                Germany                      #
#                                             #
#           tel: +49 (0)2461 61 4273          #
#           fax:                4443          #
#         email: m DOT buchmeier AT fz-juelich DOT de    #
###############################################



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