Mail Archives: djgpp/2001/02/25/14:56:54
"Michael Allison" <michael DOT allison2 AT sympatico DOT ca> wrote in message
news:Q3dm6.227124$Pm2 DOT 3685779 AT news20 DOT bellglobal DOT com...
> > > Let's constructively try to come up with the absolute minimum set
> > > of two programs that can cause the problem to occur, as a start
> > > to understanding it.
> >
> > There is obviously more to reproducing this problem than
> > nesting djgpp programs as people claim. The code below
> > went to 6 levels of nesting fine on Windows 2000 professional.
I see this foolish news software I used was awfully hard
on the tabs in the sample code I provided. Here it is with
space instead of tabs. My apologies.
We need to figure out what to add to this sample,
to get the djgpp / Windows 2000 problem to manifest
itself.
/* djgpp toplevel test program for isolating
Windows 2000 problem. parent.c */
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <process.h>
char *default_shell = "command.com";
static int execute_by_shell;
int dos_status;
int proc_return;
int nesting_level = 0;
#define CMDBUFSIZ 200
char *parentenv[] =
{
"PARENT1=environment will be",
"PARENT2=passed to child process",
(char *)0
};
char nestval[CMDBUFSIZ];
char *args[] = {
"parent.exe",
nestval,
(char *)0
};
int main(int argc, char *argv[])
{
char mycmdline[CMDBUFSIZ];
execute_by_shell = 0;
if (argc > 1)
nesting_level = atoi(argv[1]);
nesting_level++;
if (nesting_level > 300) return 0;
(void) itoa(nesting_level, nestval, 10);
printf("\nIn child, nesting level %s (by %s)\n",
nestval,
execute_by_shell ? default_shell : "spawnvpe");
if (execute_by_shell) {
char *cmdline = mycmdline;
(void) strncpy(mycmdline, argv[0],
CMDBUFSIZ - (sizeof(nesting_level) + 1));
(void) strcat(mycmdline, " ");
(void) strcat(mycmdline, nestval);
proc_return = system (cmdline);
} else {
proc_return = spawnvpe (P_WAIT, args[0],
args, parentenv);
}
/* If the child got a signal, dos_status has its
high 8 bits set, so be careful not to alter them. */
if (proc_return == -1)
dos_status |= 0xff;
else
dos_status |= (proc_return & 0xff);
return dos_status;
}
- Raw text -