Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exec, spawn and system.

Status
Not open for further replies.

emart

Programmer
Apr 26, 2000
11
0
0
US
I've read many descriptions of the EXECL function but I don't get it!&nbsp;&nbsp;One book defines it this way:<br><br>execl(filename, arg0, [arg1, ...argn, NULL)<br><br>&nbsp;&nbsp;&nbsp;filename = string containing the name of program to execute.<br>&nbsp;&nbsp;&nbsp;arg0 = first string on the command line; normally the name of the program<br>&nbsp;&nbsp;&nbsp;arg1 = next string on the command line with a space in between each arg<br><br>Why are filename and arg0 the same thing.&nbsp;&nbsp;What is their functional difference?&nbsp;&nbsp;<br><br>When I run the code in WinNT, I get an error<br>&quot;The NTVDM CPU has encountered an illegal instruction.&nbsp;&nbsp;CS:04df IP:0100 OP:63 3a 5c 73 61&quot;&nbsp;&nbsp;&nbsp;<br><br>I appreciate your help on this!<br><br>Thanks for your help?
 
Look up the CreateProcess function in your help file:<br>The CreateProcess function creates a new process and its primary thread. The new process executes the specified executable file.<br>It may be what you are looking for.<br>&nbsp; <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
Help file?&nbsp;&nbsp;I use Power C 2.2.1 -- there is no help file nor a CreateProcess function.&nbsp;&nbsp;What compiler would you recommend that is not expensive?&nbsp;&nbsp;&nbsp;I work in WinNT and UNIX.&nbsp;&nbsp;My Power C still has the limits of DOS.&nbsp;&nbsp;<br><br>
 
Hi , <br><br>&nbsp;I am giving documents to differentiate between. System and Spawn functions. As I've already given info about execl. <br>Please have a look over it. The answer is long because you have asked very general question. <br><br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A><br><br>--------------- System () ------------------------------<br>The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). If command is NULL, the function simply checks to see whether the command interpreter exists.<br><br>You must explicitly flush (using fflush or _flushall) or close any stream before calling system.Return Value<br><br>If command is NULL and the command interpreter is found, the function returns a nonzero value. If the command interpreter is not found, it returns 0 and sets errno to ENOENT. If command is not NULL, system returns the value that is returned by the command interpreter. It returns the value 0 only if the command interpreter returns the value 0. A return value of – 1 indicates an error, and errno is set to one of the following values:<br><br>E2BIG<br><br>Argument list (which is system-dependent) is too big.<br><br>ENOENT<br><br>Command interpreter cannot be found.<br><br>ENOEXEC<br><br>Command-interpreter file has invalid format and is not executable.<br><br>ENOMEM<br><br>Not enough memory is available to execute command; or available memory has been corrupted; or invalid block exists, indicating that process making call was not allocated properly.<br><br><br><br>------------------SPAWN () FUNCTION--------------------<br><br><br>Enough memory must be available for loading and executing the new process. The mode argument determines the action taken by the calling process before and during _spawn. The following values for mode are defined in PROCESS.H:<br><br>_P_OVERLAY<br><br>Overlays calling process with new process, destroying the calling process (same effect as _exec calls).<br><br>_P_WAIT<br><br>Suspends calling thread until execution of new process is complete (synchronous _spawn).<br><br>_P_NOWAIT or _P_NOWAITO<br><br>Continues to execute calling process concurrently with new process (asynchronous _spawn). <br><br>_P_DETACH<br><br>Continues to execute the calling process; new process is run in the background with no access to the console or keyboard. Calls to _cwait against the new process will fail (asynchronous _spawn).<br><br>The cmdname argument specifies the file that is executed as the new process and can specify a full path (from the root), a partial path (from the current working directory), or just a filename. If cmdname does not have a filename extension or does not end with a period (.), the _spawn function first tries the .COM extension, then the .EXE extension, the .BAT extension, and finally the .CMD extension.<br><br>If cmdname has an extension, only that extension is used. If cmdname ends with a period, the _spawn call searches for cmdname with no extension. The _spawnlp, _spawnlpe, _spawnvp, and _spawnvpe functions search for cmdname (using the same procedures) in the directories specified by the PATH environment variable.<br><br>If cmdname contains a drive specifier or any slashes (that is, if it is a relative path), the _spawn call searches only for the specified file; no path searching is done.<br><br><br><br>
 
emart:<br><br>Oh... I thought you were compiling a Windows program:<br><br>&quot;When I run the code in WinNT, I get an error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The NTVDM CPU has encountered an illegal instruction.&nbsp;&nbsp;CS:04df IP:0100 OP:63 3a 5c 73 61&quot;<br><br>There are several free C & C++ compilers on the net. The easiest to use that I've found is LCC It has a nice IDE and a Win32 hlp file. DJGPP is also a popular compiler. It needs a DMPI host (Such as provided by Windows), but produces DOS like code. You can also use it to compile Windows programs but I've never tried it. Below are two sites that have free compilers:<br><br><A HREF=" TARGET="_new"> HREF=" TARGET="_new"> <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top