delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/01/23/22:46:26

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "one2001boy AT yahoo DOT com" <one2001boy AT yahoo DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040514
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ls.exe in execv
References: <Id3Id.13792$5R DOT 2943 AT newssvr21 DOT news DOT prodigy DOT com> <35cphlF4jfqigU1 AT individual DOT net>
In-Reply-To: <35cphlF4jfqigU1@individual.net>
Lines: 71
Message-ID: <Z1_Id.14981$5R.8889@newssvr21.news.prodigy.com>
NNTP-Posting-Host: 68.124.185.24
X-Complaints-To: abuse AT prodigy DOT net
X-Trace: newssvr21.news.prodigy.com 1106537721 ST000 68.124.185.24 (Sun, 23 Jan 2005 22:35:21 EST)
NNTP-Posting-Date: Sun, 23 Jan 2005 22:35:21 EST
Organization: SBC http://yahoo.sbc.com
X-UserInfo1: F[OSS_GGVJB_GZI]]RKB_UDAZZ\DPCPDLXUNNHLHQAVTUZ]CLNTCPFK[WDXDHV[K^FCGJCJLPF_D_NCC AT FUG^Q\DINVAXSLIFXYJSSCCALP AT PB@\OS AT BITWAH\CQZKJMMD^SJA^NXA\GVLSRBD^M_NW_F[YLVTWIGAXAQBOATKBBQRXECDFDMQ\DZFUE@\JM
Date: Mon, 24 Jan 2005 03:35:21 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Martin Ambuhl wrote:
> one2001boy AT yahoo DOT com wrote:
> 
>> Hello,
>>
>> In windows,
>>
>> does anybody know if there is a solution for not hanging when run 
>> execv()? it seems that running notepad.exe is fine, however, running 
>> "ls.exe" compiled with djgpp will hangup the application. Here is the 
>> the sample code.
>>
>> #include <windows.h>
> 
> 
> Why is this posted in news:comp.os.msdos.djgpp?

I know windows.h is not part of djgpp. I thought the problem is related 
to "ls.exe" generated in djgpp. It might be wrong.

Thanks for you and all people's help. I will further look into the problem.


> 
> A corrected version of your code works fine:
> #include <stdio.h>
> #include <unistd.h>             /* needed for execv */
> #include <stdlib.h>             /* needed for exit */
> int main(void)
> {
>     int retval;
>     char *argv[] = { "C:/djgpp/bin/ls.exe", "C:/", NULL };
>     retval = execv("C:/djgpp/bin/ls.exe", argv);
>     printf("if successful, this should not be printed out\n");
>     if (retval == -1) {
>         fprintf(stderr, "ERROR: 'exec' failed\n");
>         perror("exec");
>         exit(EXIT_FAILURE); /* fixed */
>     }
>     exit(0);
> }
> 
> 
> 
> 
>> #include <stdio.h>
>> int main() {
>>     char ** environ=_environ;/**** SYSTEM DEFINED ENVIRONMENT POINTER */
>>     int retval;
>>
>>     /* this is OK
>>     char *argv[] = {"C:\\WINDOWS\\SYSTEM32\\notepad.exe", NULL};
>>     retval = execv("C:\\WINDOWS\\SYSTEM32\\notepad.exe",  argv);
>>     */
>>
>>     /*  this will hang
>>     */
>>     char *argv[] = {"C:\\bin\\ls.exe", "C:\\", NULL};
>>     retval = execv("C:\\bin\\ls.exe",  argv);
>>
>>     printf("if successful, this should not be printed out\n");
>>     if(retval == -1) {
>>         fprintf(stderr, "ERROR: 'exec' failed\n");
>>         perror("exec");
>>         exit(-1);
>>     }
>>     exit(0);
>> }
>>
>>
>> thanks.

- Raw text -


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