From: paag AT tid DOT es ("Pedro A. Aranda =?iso-8859-1?Q?Guti=E9rrez?=") Subject: Problem using bash a the default shell from within a non cygwin32 program & crashes with ^C 14 Dec 1996 08:39:28 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <32B2CFC8.52B9.cygnus.gnu-win32@tid.es> References: <199612140537 DOT IAA10146 AT buggy DOT prospect DOT com DOT ru> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Mailer: Mozilla 3.0 (Win95; I) Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com Hi, everybody! Is this a bug, or just a 'negative feature' ??? I'm trying to avoid having multiple copies of bash under different names in my system. The first way I thought of writing simple 100% WIN32 program I had already used in a port of a 'make' utility I did some time ago. I just substitute argv[0] by 'bash' and take the rest of arguments into a new command line and use the Win32 API to execute the command. Here's the source: ----------- sh.c ----------------------------- #include #include #include #include #include int main(int argc,char **argv) { int bResult; STARTUPINFO si; PROCESS_INFORMATION pi; DWORD exitcode; char* cmd; int cmdlen; int arg; = cmd =3D malloc(5); strcpy(cmd,"bash"); cmdlen =3D 5; for(arg=3D1;arg < argc;arg ++) { char *tmp; cmdlen +=3D strlen(argv[arg]) + 1; if ((tmp =3D malloc(cmdlen)) =3D=3D NULL) return -1; sprintf(tmp,"%s %s",cmd,argv[arg]); free(cmd); cmd =3D tmp; } = exitcode =3D 0; memset(&si,0,sizeof(STARTUPINFO)); si.cb =3D sizeof(STARTUPINFO); = bResult =3D CreateProcess(NULL, cmd, NULL,NULL, /* No security */ TRUE, /* Inherits handles */ 0, /* Runs normally */ NULL,NULL, /* Inherits env & cwd */ &si,&pi); = if (bResult) { while (bResult =3D GetExitCodeProcess(pi.hProcess,&exitcode)) if (exitcode !=3D STILL_ACTIVE) break; = if (bResult =3D=3D FALSE) { printf("GetExitCodeProcess() returned FALSE\n"); return -1; } } else { exitcode =3D -1; } = return (int)exitcode; } ---------------------------------------------- I saw, that something wasn't quite right, so I wrote this absolutely studip test program ---------------- kk.c ------------------------ #include int main(int argc, char **argv) { int arg; = printf("kk: argc =3D %d\n",argc); for (arg =3D 0;arg < argc;arg++) printf("kk: argv[%d] =3D '%s'\n",arg,argv[arg]); = } ---------------------------------------------- And the results speak for themselves : ---------------------------------------------- sh -c ./kk hi, how are you kk: argc =3D 1 kk: argv[0] =3D './kk' ---------------------------------------------- Now, IMHO, the problem is somehow in 'bash'. Any clues? = Ahh, BTW If I try to abort a make with a Ctrl-c = from within a DOS box in Win95 running COMMAND.COM, I get this wonderful 'myriad' of messages: C:\users\demo>make gcc -c main.c -o main.o wait_for_any: WaitForMultipleObjects failed, win32 error 6 wait_for_any: Trying again. gcc: Internal compiler error: program cc1 got fatal signal 127 MAKE.EXE: *** [main.o] Error 1 wait_found: GetExitCodeProcess failed! wait_found: CloseHandle process failed wait_found: CloseHandle thread failed MAKE.EXE: *** [Unknown job 1001] Error 1 and win95 complaining about a page fault in CYGWIN.DLL: GCC provoc=F3 un fallo de p=E1gina no v=E1lida en el = m=F3dulo CYGWIN.DLL de 0137:10031800. Registros: EAX=3D0254fb28 CS=3D0137 EIP=3D10031800 EFLGS=3D00010206 EBX=3D00000001 SS=3D013f ESP=3D0456ff40 EBP=3D0456ff48 ECX=3D00000001 DS=3D013f ESI=3D00000028 FS=3D2f8f EDX=3D82980628 ES=3D013f EDI=3D00000000 GS=3D0000 Bytes en CS:EIP: 8b 5e 04 4b 78 09 8b 44 9e 08 ff d0 4b 79 f7 8b = Volcado de pila: 00000001 0000000c 0456ff64 100129cb 00010100 00000000 8155ca3c 00000000 00000001 0456ff80 bff9e62c 00000000 00000000 81562af4 81562fa0 0456ff70 = It gets even worse when running from 'bash' I hope this information helps hunting down the problems I've experienced. I'm not able to download everything (the sources are sooo big) and I'm just running a 14.4 K line (the cdk was enough pain). (Well, I'm running the spanish version of Win95, with Service Pack 1 installed). -- = Pedro Andr=E9s Aranda Guti=E9rrez - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".