X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "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: <35cphlF4jfqigU1 AT individual DOT net> In-Reply-To: <35cphlF4jfqigU1@individual.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 71 Message-ID: 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 > > > 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 > #include /* needed for execv */ > #include /* 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 >> 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.