X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=lvP6Fe/bNS+yvVWHC7EdG1ZGAgU5j7CR5PnUain+ZdYJEGaF3q4Ll8VnV/tVZrk54mCGWybv8hlU/VVnRWKuYkWB4bAjwzUdahqE3PbqZGId6NupZquwt85xk83kEpJf4MnNSzKWT4BpVschS2+Nw7rbH6DRTls5KyUOF3hnpEE= Message-ID: Date: Fri, 21 Jan 2005 08:42:52 -0600 From: Andrew Paulsen To: djgpp AT delorie DOT com Subject: RE: ls.exe in execv Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com >> 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 >> #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); >> } I think there are a couple problems with this. First, you may not want to destroy argv[] like that so I'd change it to a different name. Second, why are you passing the path to ls in the argv[] parameter? The following worked for me: #include #include #include int main() { int retval; char *myArgv[] = {"C:\\", NULL}; retval = execv("C:\\djgpp\\bin\\ls.exe", myArgv); printf("if successful, this should not be printed out\n"); if(retval == -1) { perror("exec"); exit(-1); } exit(0); } Andrew