Changeset 2596 for vendor/gnumake/current/vmsjobs.c
- Timestamp:
- Jun 20, 2012, 12:44:52 AM (13 years ago)
- Location:
- vendor/gnumake/current
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current
- Property svn:ignore deleted
-
vendor/gnumake/current/vmsjobs.c
- Property svn:keywords deleted
r1989 r2596 3 3 4 4 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 5 2007 Free Software Foundation, Inc.5 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 6 6 This file is part of GNU Make. 7 7 … … 111 111 } 112 112 113 /* This is called as an AST when a child process dies (it won't get 114 interrupted by anything except a higher level AST). 113 static int ctrlYPressed= 0; 114 /* This is called at main or AST level. It is at AST level for DONTWAITFORCHILD 115 and at main level otherwise. In any case it is called when a child process 116 terminated. At AST level it won't get interrupted by anything except a 117 inner mode level AST. 115 118 */ 116 119 int … … 124 127 125 128 lib$free_ef(&child->efn); 129 if (child->comname) 130 { 131 if (!ISDB (DB_JOBS)&&!ctrlYPressed) 132 unlink (child->comname); 133 free (child->comname); 134 } 126 135 127 136 (void) sigblock (fatal_signal_mask); … … 220 229 static int oldCtrlMask; 221 230 static int setupYAstTried= 0; 222 static int pidToAbort= 0; 223 static int chan= 0; 231 static unsigned short int chan= 0; 224 232 225 233 static void … … 229 237 } 230 238 231 static void232 ast Handler (void)239 static int 240 astYHandler (void) 233 241 { 234 if (pidToAbort) {235 sys$forcex (&pidToAbort, 0, SS$_ABORT);236 pidToAbort= 0;237 }242 struct child *c; 243 for (c = children; c != 0; c = c->next) 244 sys$delprc (&c->pid, 0, 0); 245 ctrlYPressed= 1; 238 246 kill (getpid(),SIGQUIT); 247 return SS$_NORMAL; 239 248 } 240 249 … … 248 257 int dvi; 249 258 } iosb; 259 unsigned short int loc_chan; 250 260 251 261 setupYAstTried++; 252 262 253 if (!chan) { 254 status= sys$assign(&inputDsc,&chan,0,0); 263 if (chan) 264 loc_chan= chan; 265 else { 266 status= sys$assign(&inputDsc,&loc_chan,0,0); 255 267 if (!(status&SS$_NORMAL)) { 256 268 lib$signal(status); … … 258 270 } 259 271 } 260 status= sys$qiow (0, chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0, 261 astHandler,0,0,0,0,0); 262 if (status==SS$_NORMAL) 263 status= iosb.status; 264 if (status==SS$_ILLIOFUNC || status==SS$_NOPRIV) { 265 sys$dassgn(chan); 266 #ifdef CTRLY_ENABLED_ANYWAY 267 fprintf (stderr, 268 _("-warning, CTRL-Y will leave sub-process(es) around.\n")); 269 #else 270 return; 271 #endif 272 } 273 else if (!(status&SS$_NORMAL)) { 274 sys$dassgn(chan); 275 lib$signal(status); 272 status= sys$qiow (0, loc_chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0, 273 astYHandler,0,0,0,0,0); 274 if (status==SS$_NORMAL) 275 status= iosb.status; 276 if (status!=SS$_NORMAL) { 277 if (!chan) 278 sys$dassgn(loc_chan); 279 if (status!=SS$_ILLIOFUNC && status!=SS$_NOPRIV) 280 lib$signal(status); 276 281 return; 277 282 } … … 288 293 return; 289 294 } 295 if (!chan) 296 chan = loc_chan; 290 297 } 291 298 … … 300 307 static struct dsc$descriptor_s efiledsc; 301 308 int have_redirection = 0; 309 int have_append = 0; 302 310 int have_newline = 0; 303 311 … … 306 314 char *cmd = alloca (strlen (argv) + 512), *p, *q; 307 315 char ifile[256], ofile[256], efile[256]; 308 char *comname = 0;316 int comnamelen; 309 317 char procname[100]; 310 318 int in_string; … … 315 323 ofile[0] = 0; 316 324 efile[0] = 0; 325 child->comname = NULL; 317 326 318 327 DB (DB_JOBS, ("child_execute_job (%s)\n", argv)); … … 384 393 else 385 394 { 395 if (*(p+1) == '>') 396 { 397 have_append = 1; 398 p += 1; 399 } 386 400 p = vms_redirect (&ofiledsc, ofile, p); 387 401 } … … 482 496 } 483 497 484 outfile = open_tmpfile (&c omname, "sys$scratch:CMDXXXXXX.COM");498 outfile = open_tmpfile (&child->comname, "sys$scratch:CMDXXXXXX.COM"); 485 499 if (outfile == 0) 486 500 pfatal_with_name (_("fopen (temporary file)")); 501 comnamelen = strlen (child->comname); 487 502 488 503 if (ifile[0]) … … 502 517 if (ofile[0]) 503 518 { 504 fprintf (outfile, "$ define sys$output %s\n", ofile); 505 DB (DB_JOBS, (_("Redirected output to %s\n"), ofile)); 506 ofiledsc.dsc$w_length = 0; 519 if (have_append) 520 { 521 fprintf (outfile, "$ set noon\n"); 522 fprintf (outfile, "$ define sys$output %.*s\n", comnamelen-3, child->comname); 523 DB (DB_JOBS, (_("Append output to %s\n"), ofile)); 524 ofiledsc.dsc$w_length = 0; 525 } 526 else 527 { 528 fprintf (outfile, "$ define sys$output %s\n", ofile); 529 DB (DB_JOBS, (_("Redirected output to %s\n"), ofile)); 530 ofiledsc.dsc$w_length = 0; 531 } 507 532 } 508 533 … … 559 584 } 560 585 561 fwrite (p, 1, q - p, outfile); 586 if (*p) 587 { 588 fwrite (p, 1, --q - p, outfile); 562 589 fputc ('\n', outfile); 590 } 591 592 if (have_append) 593 { 594 fprintf (outfile, "$ deassign sys$output ! 'f$verify(0)\n"); 595 fprintf (outfile, "$ append:=append\n"); 596 fprintf (outfile, "$ delete:=delete\n"); 597 fprintf (outfile, "$ append/new %.*s %s\n", comnamelen-3, child->comname, ofile); 598 fprintf (outfile, "$ delete %.*s;*\n", comnamelen-3, child->comname); 599 DB (DB_JOBS, (_("Append %.*s and cleanup\n"), comnamelen-3, child->comname)); 600 } 563 601 564 602 fclose (outfile); 565 603 566 sprintf (cmd, "$ @%s", c omname);604 sprintf (cmd, "$ @%s", child->comname); 567 605 568 606 DB (DB_JOBS, (_("Executing %s instead\n"), cmd)); … … 579 617 status = lib$get_ef ((unsigned long *)&child->efn); 580 618 if (!(status & 1)) 581 return 0; 619 { 620 if (child->comname) 621 { 622 if (!ISDB (DB_JOBS)) 623 unlink (child->comname); 624 free (child->comname); 625 } 626 return 0; 627 } 582 628 } 583 629 … … 648 694 if (status & 1) 649 695 { 650 pidToAbort= child->pid;651 696 status= sys$waitfr (child->efn); 652 pidToAbort= 0;653 697 vmsHandleChildTerm(child); 654 698 } … … 678 722 } 679 723 680 if (comname && !ISDB (DB_JOBS))681 unlink (comname);682 683 724 return (status & 1); 684 725 }
Note:
See TracChangeset
for help on using the changeset viewer.