aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2016-06-09 21:58:16 -0700
committerPaul Eggert2016-06-09 21:58:53 -0700
commit560202f67513327f5b262e01ebc709ab6855d6f6 (patch)
tree282f79044a059e8bc028b5a24109bdde749e921f /src/process.c
parent48079f68125e75cf581ef2b86b00c5a3851dd6e7 (diff)
downloademacs-560202f67513327f5b262e01ebc709ab6855d6f6.tar.gz
emacs-560202f67513327f5b262e01ebc709ab6855d6f6.zip
Fix XFASTINT of non-fixnum in process status
* src/process.c (decode_status): 3rd arg is now Lisp_Object *, not int *, and is not decoded. All uses changed. (status_message): Do not assume ‘failed’ code is an integer. * src/process.h: Document codes better.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/process.c b/src/process.c
index 9ca3e594355..5e06ccccac8 100644
--- a/src/process.c
+++ b/src/process.c
@@ -537,21 +537,22 @@ status_convert (int w)
537 and store them individually through the three pointers. */ 537 and store them individually through the three pointers. */
538 538
539static void 539static void
540decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, bool *coredump) 540decode_status (Lisp_Object l, Lisp_Object *symbol, Lisp_Object *code,
541 bool *coredump)
541{ 542{
542 Lisp_Object tem; 543 Lisp_Object tem;
543 544
544 if (SYMBOLP (l)) 545 if (SYMBOLP (l))
545 { 546 {
546 *symbol = l; 547 *symbol = l;
547 *code = 0; 548 *code = make_number (0);
548 *coredump = 0; 549 *coredump = 0;
549 } 550 }
550 else 551 else
551 { 552 {
552 *symbol = XCAR (l); 553 *symbol = XCAR (l);
553 tem = XCDR (l); 554 tem = XCDR (l);
554 *code = XFASTINT (XCAR (tem)); 555 *code = XCAR (tem);
555 tem = XCDR (tem); 556 tem = XCDR (tem);
556 *coredump = !NILP (tem); 557 *coredump = !NILP (tem);
557 } 558 }
@@ -563,8 +564,7 @@ static Lisp_Object
563status_message (struct Lisp_Process *p) 564status_message (struct Lisp_Process *p)
564{ 565{
565 Lisp_Object status = p->status; 566 Lisp_Object status = p->status;
566 Lisp_Object symbol; 567 Lisp_Object symbol, code;
567 int code;
568 bool coredump; 568 bool coredump;
569 Lisp_Object string; 569 Lisp_Object string;
570 570
@@ -574,7 +574,7 @@ status_message (struct Lisp_Process *p)
574 { 574 {
575 char const *signame; 575 char const *signame;
576 synchronize_system_messages_locale (); 576 synchronize_system_messages_locale ();
577 signame = strsignal (code); 577 signame = strsignal (XFASTINT (code));
578 if (signame == 0) 578 if (signame == 0)
579 string = build_string ("unknown"); 579 string = build_string ("unknown");
580 else 580 else
@@ -596,20 +596,20 @@ status_message (struct Lisp_Process *p)
596 else if (EQ (symbol, Qexit)) 596 else if (EQ (symbol, Qexit))
597 { 597 {
598 if (NETCONN1_P (p)) 598 if (NETCONN1_P (p))
599 return build_string (code == 0 ? "deleted\n" : "connection broken by remote peer\n"); 599 return build_string (XFASTINT (code) == 0
600 if (code == 0) 600 ? "deleted\n"
601 : "connection broken by remote peer\n");
602 if (XFASTINT (code) == 0)
601 return build_string ("finished\n"); 603 return build_string ("finished\n");
602 AUTO_STRING (prefix, "exited abnormally with code "); 604 AUTO_STRING (prefix, "exited abnormally with code ");
603 string = Fnumber_to_string (make_number (code)); 605 string = Fnumber_to_string (code);
604 AUTO_STRING (suffix, coredump ? " (core dumped)\n" : "\n"); 606 AUTO_STRING (suffix, coredump ? " (core dumped)\n" : "\n");
605 return concat3 (prefix, string, suffix); 607 return concat3 (prefix, string, suffix);
606 } 608 }
607 else if (EQ (symbol, Qfailed)) 609 else if (EQ (symbol, Qfailed))
608 { 610 {
609 AUTO_STRING (prefix, "failed with code "); 611 AUTO_STRING (format, "failed with code %s\n");
610 string = Fnumber_to_string (make_number (code)); 612 return CALLN (Fformat, format, code);
611 AUTO_STRING (suffix, "\n");
612 return concat3 (prefix, string, suffix);
613 } 613 }
614 else 614 else
615 return Fcopy_sequence (Fsymbol_name (symbol)); 615 return Fcopy_sequence (Fsymbol_name (symbol));