www.digitalmars.com         C & C++   DMDScript  

c++.dos.32-bits - _spawnl general protection fault error

reply E. Trelmar <E._member pathlink.com> writes:
I'm probably just coding something wrong, but every time I try to _spawnl a
certain program, I get an 0Dh (Hard Disk) general protection fault, possible
illegal memory address. I use the _P_WAIT style (spawn and wait till
termination) rather than the overlay and terminate parent process. I'm assuming
that the program (developed third-party) is 16-bit, and doesn't run in protected
mode from a direct spawn, I'm not sure though.
How does one spawn a 16 bit real-mode program from a 32-bit protected mode
program?

The program in question is tiffcp.exe, a free tool for collating .tif images.
Jul 10 2002
parent reply "Walter" <walter digitalmars.com> writes:
Try building a simple hello world program and see if that can be
successfully spawned. -Walter

"E. Trelmar" <E._member pathlink.com> wrote in message
news:aghoa0$1j84$1 digitaldaemon.com...
 I'm probably just coding something wrong, but every time I try to _spawnl
a
 certain program, I get an 0Dh (Hard Disk) general protection fault,
possible
 illegal memory address. I use the _P_WAIT style (spawn and wait till
 termination) rather than the overlay and terminate parent process. I'm
assuming
 that the program (developed third-party) is 16-bit, and doesn't run in
protected
 mode from a direct spawn, I'm not sure though.
 How does one spawn a 16 bit real-mode program from a 32-bit protected mode
 program?

 The program in question is tiffcp.exe, a free tool for collating .tif
images.

Jul 10 2002
parent reply E. Trelmar <E._member pathlink.com> writes:
In article <aghpm8$1kt7$2 digitaldaemon.com>, Walter says...
Try building a simple hello world program and see if that can be
successfully spawned. -Walter
I should have specified, it doesn't spawn any 16 bit programs. I just tried 32-bit programs though, going off a tangent on your suggestion, and those generate the same error. So I tried generating a 32-bit program with nothing but a _spawnl command. It won't spawn either 32-bit or 16-bit programs (Again, the same error). Is this simply my machine? Can anyone else get _spawnl to work in 32-bit dos?
Jul 10 2002
parent reply "Walter" <walter digitalmars.com> writes:
"E. Trelmar" <E._member pathlink.com> wrote in message
news:aghqk5$1lht$1 digitaldaemon.com...
 I should have specified, it doesn't spawn any 16 bit programs. I just
tried
 32-bit programs though, going off a tangent on your suggestion, and those
 generate the same error. So I tried generating a 32-bit program with
nothing but
 a _spawnl command. It won't spawn either 32-bit or 16-bit programs (Again,
the
 same error). Is this simply my machine? Can anyone else get _spawnl to
work in
 32-bit dos?
I use this program all the time and it spawns successfully. --------------------------------------------------------- /*_ timer.c Mon Feb 29 1988 Modified by: Walter Bright */ /* Written by Walter Bright */ #include <stdio.h> #include <stdlib.h> #if _WIN32 #include <windows.h> typedef long long timer_t; #else #include <time.h> #endif #if __SC__ && !_WIN32 int _okbigbuf = 0; /* Use as little memory as possible */ #endif int main(argc,argv) int argc; char *argv[]; { int status; #if _WIN32 timer_t starttime; timer_t freq; timer_t endtime; timer_t secs; timer_t fraction; if (argc < 2) { printf("Time execution of a command.\nUse:\n\ttimer command\n"); exit(EXIT_FAILURE); } argv[argc] = 0; /* terminate with a 0 (unportable method) */ QueryPerformanceFrequency((LARGE_INTEGER *)&freq); QueryPerformanceCounter((LARGE_INTEGER *)&starttime); status = spawnvp(0,argv[1],argv + 1); QueryPerformanceCounter((LARGE_INTEGER *)&endtime); if (status == -1) { printf("'%s' failed to execute\n",argv[1]); exit(EXIT_FAILURE); } starttime = endtime - starttime; secs = starttime / freq; starttime -= secs * freq; fraction = (starttime * 10000) / freq; printf("Elapsed time = %lld.%04lld seconds\n",secs,fraction); #else clock_t clock(),starttime; if (argc < 2) { printf("Time execution of a command.\nUse:\n\ttimer command\n"); exit(1); } argv[argc] = 0; /* terminate with a 0 (unportable method) */ starttime = clock(); status = spawnvp(0,argv[1],argv + 1); starttime = clock() - starttime; if (status == -1) { printf("'%s' failed to execute\n",argv[1]); exit(1); } printf("Elapsed time = %d.%02d seconds\n",(int) (starttime/CLK_TCK), (int) (starttime%CLK_TCK)); #endif if (status != 0) printf("--- errorlevel %d\n",status); return status; } #if __SC__ && !_WIN32 /* Prevent exit() and fclose() from being linked in from library */ /* (to conserve the size of the output file). */ void exit(exitstatus) int exitstatus; { _exit(exitstatus); } #endif
Jul 10 2002
parent E. Trelmar <E._member pathlink.com> writes:
Both your program Walter (With process.h #included so it compiles for me) and
the example programs work successfully. Luckily, I just found out the problem
was that I wasn't passing a final NULL pointer to the spawnl series. Thank you
for the replies, I appreciate the help.
Jul 11 2002