diff options
| author | Andrew Innes | 1998-12-28 19:25:28 +0000 |
|---|---|---|
| committer | Andrew Innes | 1998-12-28 19:25:28 +0000 |
| commit | d78e84f792e68c4db0e775a977c70e09871d23e1 (patch) | |
| tree | 9264a9d7d8c8b8aee122233cbcf4a952c5fc4f01 /nt/cmdproxy.c | |
| parent | 9d52160a5c4cbeb9486b7bba1faeaedadf6d75a0 (diff) | |
| download | emacs-d78e84f792e68c4db0e775a977c70e09871d23e1.tar.gz emacs-d78e84f792e68c4db0e775a977c70e09871d23e1.zip | |
(spawn): Pass directory for child as parameter.
(main): Save startup directory to give to spawn, then change directory
to location of .exe in order not to prevent startup directory from
being deleted.
Diffstat (limited to 'nt/cmdproxy.c')
| -rw-r--r-- | nt/cmdproxy.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c index ce72ba129c9..0ca57abb5ca 100644 --- a/nt/cmdproxy.c +++ b/nt/cmdproxy.c | |||
| @@ -369,7 +369,7 @@ console_event_handler (DWORD event) | |||
| 369 | /* Change from normal usage; return value indicates whether spawn | 369 | /* Change from normal usage; return value indicates whether spawn |
| 370 | succeeded or failed - program return code is returned separately. */ | 370 | succeeded or failed - program return code is returned separately. */ |
| 371 | int | 371 | int |
| 372 | spawn (char * progname, char * cmdline, int * retcode) | 372 | spawn (char * progname, char * cmdline, char * dir, int * retcode) |
| 373 | { | 373 | { |
| 374 | BOOL success = FALSE; | 374 | BOOL success = FALSE; |
| 375 | SECURITY_ATTRIBUTES sec_attrs; | 375 | SECURITY_ATTRIBUTES sec_attrs; |
| @@ -388,7 +388,7 @@ spawn (char * progname, char * cmdline, int * retcode) | |||
| 388 | start.cb = sizeof (start); | 388 | start.cb = sizeof (start); |
| 389 | 389 | ||
| 390 | if (CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE, | 390 | if (CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE, |
| 391 | 0, envblock, NULL, &start, &child)) | 391 | 0, envblock, dir, &start, &child)) |
| 392 | { | 392 | { |
| 393 | success = TRUE; | 393 | success = TRUE; |
| 394 | /* wait for completion and pass on return code */ | 394 | /* wait for completion and pass on return code */ |
| @@ -432,12 +432,16 @@ main (int argc, char ** argv) | |||
| 432 | int num_pass_through_args; | 432 | int num_pass_through_args; |
| 433 | char modname[MAX_PATH]; | 433 | char modname[MAX_PATH]; |
| 434 | char path[MAX_PATH]; | 434 | char path[MAX_PATH]; |
| 435 | char dir[MAX_PATH]; | ||
| 435 | 436 | ||
| 436 | 437 | ||
| 437 | interactive = TRUE; | 438 | interactive = TRUE; |
| 438 | 439 | ||
| 439 | SetConsoleCtrlHandler ((PHANDLER_ROUTINE) console_event_handler, TRUE); | 440 | SetConsoleCtrlHandler ((PHANDLER_ROUTINE) console_event_handler, TRUE); |
| 440 | 441 | ||
| 442 | if (!GetCurrentDirectory (sizeof (dir), dir)) | ||
| 443 | fail ("error: GetCurrentDirectory failed\n"); | ||
| 444 | |||
| 441 | /* We serve double duty: we can be called either as a proxy for the | 445 | /* We serve double duty: we can be called either as a proxy for the |
| 442 | real shell (that is, because we are defined to be the user shell), | 446 | real shell (that is, because we are defined to be the user shell), |
| 443 | or in our role as a helper application for running DOS programs. | 447 | or in our role as a helper application for running DOS programs. |
| @@ -453,6 +457,13 @@ main (int argc, char ** argv) | |||
| 453 | if (!GetModuleFileName (NULL, modname, sizeof (modname))) | 457 | if (!GetModuleFileName (NULL, modname, sizeof (modname))) |
| 454 | fail ("error: GetModuleFileName failed\n"); | 458 | fail ("error: GetModuleFileName failed\n"); |
| 455 | 459 | ||
| 460 | /* Change directory to location of .exe so startup directory can be | ||
| 461 | deleted. */ | ||
| 462 | progname = strrchr (modname, '\\'); | ||
| 463 | *progname = '\0'; | ||
| 464 | SetCurrentDirectory (modname); | ||
| 465 | *progname = '\\'; | ||
| 466 | |||
| 456 | /* Although Emacs always sets argv[0] to an absolute pathname, we | 467 | /* Although Emacs always sets argv[0] to an absolute pathname, we |
| 457 | might get run in other ways as well, so convert argv[0] to an | 468 | might get run in other ways as well, so convert argv[0] to an |
| 458 | absolute name before comparing to the module name. */ | 469 | absolute name before comparing to the module name. */ |
| @@ -462,7 +473,7 @@ main (int argc, char ** argv) | |||
| 462 | /* We are being used as a helper to run a DOS app; just pass | 473 | /* We are being used as a helper to run a DOS app; just pass |
| 463 | command line to DOS app without change. */ | 474 | command line to DOS app without change. */ |
| 464 | /* TODO: fill in progname. */ | 475 | /* TODO: fill in progname. */ |
| 465 | if (spawn (NULL, GetCommandLine (), &rc)) | 476 | if (spawn (NULL, GetCommandLine (), dir, &rc)) |
| 466 | return rc; | 477 | return rc; |
| 467 | fail ("Could not run %s\n", GetCommandLine ()); | 478 | fail ("Could not run %s\n", GetCommandLine ()); |
| 468 | } | 479 | } |
| @@ -670,7 +681,7 @@ main (int argc, char ** argv) | |||
| 670 | if (!cmdline) | 681 | if (!cmdline) |
| 671 | cmdline = progname; | 682 | cmdline = progname; |
| 672 | 683 | ||
| 673 | if (spawn (progname, cmdline, &rc)) | 684 | if (spawn (progname, cmdline, dir, &rc)) |
| 674 | return rc; | 685 | return rc; |
| 675 | 686 | ||
| 676 | if (!need_shell) | 687 | if (!need_shell) |