MCPcopy Create free account
hub / github.com/NetHack/NetHack / vms_doshell

Function vms_doshell

sys/vms/vmsunix.c:475–528  ·  view source on GitHub ↗

vms_doshell -- called by dosh() and readmail() * * If execstring is not a null string, then it will be executed in a spawned * subprocess, which will then return. It is for handling mail or phone * interactive commands, which are only available if both MAIL and SHELL are * #defined, but we don't bother making the support code conditionalized on * MAIL here, just on SHELL being enabled. *

Source from the content-addressed store, hash-verified

473 * will be piped into oblivion. Used for silent phone call rejection.
474 */
475int
476vms_doshell(const char *execstring, boolean screenoutput)
477{
478 unsigned long status, new_pid, spawnflags = 0;
479 struct dsc$descriptor_s comstring, *command, *inoutfile = 0;
480 static char dev_null[] = "_NLA0:";
481 static $DESCRIPTOR(nulldevice, dev_null);
482
483 /* Is this an interactive shell spawn, or do we have a command to do? */
484 if (execstring && *execstring) {
485 comstring.dsc$w_length = strlen(execstring);
486 comstring.dsc$b_dtype = DSC$K_DTYPE_T;
487 comstring.dsc$b_class = DSC$K_CLASS_S;
488 comstring.dsc$a_pointer = (char *) execstring;
489 command = &comstring;
490 } else
491 command = 0;
492
493 /* use asynch subprocess and suppress output iff one-shot command */
494 if (!screenoutput) {
495 spawnflags = CLI$M_NOWAIT;
496 inoutfile = &nulldevice;
497 }
498
499 hack_escape(screenoutput,
500 command ? (const char *) 0
501 : " \"Escaping\" into a subprocess; LOGOUT to reconnect and resume play. ");
502
503 if (command || !dosh_pid || !vms_ok(status = lib$attach(&dosh_pid))) {
504#ifdef CHDIR
505 (void) chdir(getenv("PATH"));
506#endif
507 privoff();
508 new_pid = 0;
509 status = lib$spawn(command, inoutfile, inoutfile, &spawnflags,
510 (struct dsc$descriptor_s *) 0, &new_pid);
511 if (!command)
512 dosh_pid = new_pid;
513 else
514 mail_pid = new_pid;
515 privon();
516#ifdef CHDIR
517 chdirx((char *) 0, 0);
518#endif
519 }
520
521 hack_resume(screenoutput);
522
523 if (!vms_ok(status)) {
524 pline(" Spawn failed. (%%x%08lX) ", status);
525 mark_synch();
526 }
527 return 0;
528}
529#endif /* SHELL */
530
531#ifdef SUSPEND

Callers 2

doshFunction · 0.85
readmailFunction · 0.85

Calls 7

hack_escapeFunction · 0.85
privoffFunction · 0.85
privonFunction · 0.85
hack_resumeFunction · 0.85
chdirxFunction · 0.70
chdirFunction · 0.50
plineFunction · 0.50

Tested by

no test coverage detected