comparison src/process.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents 7039e6323819
children fdefd0186b75
comparison
equal deleted inserted replaced
562:c775bd016b32 563:183866b06e0b
106 /* List of process objects. */ 106 /* List of process objects. */
107 Lisp_Object Vprocess_list; 107 Lisp_Object Vprocess_list;
108 108
109 extern Lisp_Object Vlisp_EXEC_SUFFIXES; 109 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
110 Lisp_Object Vnull_device; 110 Lisp_Object Vnull_device;
111
112 Lisp_Object Qprocess_error;
113 Lisp_Object Qnetwork_error;
111 114
112 115
113 116
114 static Lisp_Object 117 static Lisp_Object
115 mark_process (Lisp_Object object) 118 mark_process (Lisp_Object object)
136 print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag) 139 print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag)
137 { 140 {
138 Lisp_Process *process = XPROCESS (object); 141 Lisp_Process *process = XPROCESS (object);
139 142
140 if (print_readably) 143 if (print_readably)
141 error ("printing unreadable object #<process %s>", 144 printing_unreadable_object ("#<process %s>", XSTRING_DATA (process->name));
142 XSTRING_DATA (process->name));
143 145
144 if (!escapeflag) 146 if (!escapeflag)
145 { 147 {
146 print_internal (process->name, printcharfun, 0); 148 print_internal (process->name, printcharfun, 0);
147 } 149 }
340 342
341 buffer = Fget_buffer (name); 343 buffer = Fget_buffer (name);
342 if (BUFFERP (buffer)) 344 if (BUFFERP (buffer))
343 goto have_buffer_object; 345 goto have_buffer_object;
344 346
345 error ("Process %s does not exist", XSTRING_DATA (name)); 347 invalid_argument ("Process does not exist", name);
346 } 348 }
347 else if (NILP (name)) 349 else if (NILP (name))
348 { 350 {
349 buffer = Fcurrent_buffer (); 351 buffer = Fcurrent_buffer ();
350 goto have_buffer_object; 352 goto have_buffer_object;
357 have_buffer_object: 359 have_buffer_object:
358 process = Fget_buffer_process (buffer); 360 process = Fget_buffer_process (buffer);
359 if (PROCESSP (process)) 361 if (PROCESSP (process))
360 return process; 362 return process;
361 363
362 error ("Buffer %s has no process", 364 invalid_argument ("Buffer has no process", buffer);
363 XSTRING_DATA (XBUFFER (buffer)->name));
364 } 365 }
365 else 366 else
366 return get_process (Fsignal (Qwrong_type_argument, 367 return get_process (Fsignal (Qwrong_type_argument,
367 (list2 (build_string ("process or buffer or nil"), 368 (list2 (build_string ("process or buffer or nil"),
368 name)))); 369 name))));
411 412
412 413
413 /************************************************************************/ 414 /************************************************************************/
414 /* creating a process */ 415 /* creating a process */
415 /************************************************************************/ 416 /************************************************************************/
417
418 DOESNT_RETURN
419 report_process_error (const char *string, Lisp_Object data)
420 {
421 report_error_with_errno (Qprocess_error, string, data);
422 }
423
424 DOESNT_RETURN
425 report_network_error (const char *string, Lisp_Object data)
426 {
427 report_error_with_errno (Qnetwork_error, string, data);
428 }
416 429
417 Lisp_Object 430 Lisp_Object
418 make_process_internal (Lisp_Object name) 431 make_process_internal (Lisp_Object name)
419 { 432 {
420 Lisp_Object val, name1; 433 Lisp_Object val, name1;
467 480
468 void 481 void
469 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags) 482 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags)
470 { 483 {
471 USID usid = event_stream_create_stream_pair (in, out, 484 USID usid = event_stream_create_stream_pair (in, out,
472 &p->pipe_instream, &p->pipe_outstream, 485 &p->pipe_instream,
486 &p->pipe_outstream,
473 flags); 487 flags);
474 488
475 if (usid == USID_ERROR) 489 if (usid == USID_ERROR)
476 report_file_error ("Setting up communication with subprocess", Qnil); 490 signal_error (Qprocess_error, "Setting up communication with subprocess",
491 Qunbound);
477 492
478 if (usid != USID_DONTHASH) 493 if (usid != USID_DONTHASH)
479 { 494 {
480 Lisp_Object process = Qnil; 495 Lisp_Object process = Qnil;
481 XSETPROCESS (process, p); 496 XSETPROCESS (process, p);
585 600
586 #if 0 /* This loser breaks ange-ftp */ 601 #if 0 /* This loser breaks ange-ftp */
587 /* dmoore - if you re-enable this code, you have to gcprotect 602 /* dmoore - if you re-enable this code, you have to gcprotect
588 current_buffer through the above calls. */ 603 current_buffer through the above calls. */
589 if (NILP (Ffile_accessible_directory_p (current_dir))) 604 if (NILP (Ffile_accessible_directory_p (current_dir)))
590 report_file_error ("Setting current directory", 605 signal_error (Qprocess_error, "Setting current directory",
591 list1 (current_buffer->directory)); 606 current_buffer->directory);
592 #endif /* 0 */ 607 #endif /* 0 */
593 608
594 /* If program file name is not absolute, search our path for it */ 609 /* If program file name is not absolute, search our path for it */
595 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0)) 610 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0))
596 && !(XSTRING_LENGTH (program) > 1 611 && !(XSTRING_LENGTH (program) > 1
600 615
601 tem = Qnil; 616 tem = Qnil;
602 NGCPRO1 (tem); 617 NGCPRO1 (tem);
603 locate_file (Vexec_path, program, Vlisp_EXEC_SUFFIXES, &tem, X_OK); 618 locate_file (Vexec_path, program, Vlisp_EXEC_SUFFIXES, &tem, X_OK);
604 if (NILP (tem)) 619 if (NILP (tem))
605 report_file_error ("Searching for program", list1 (program)); 620 signal_error (Qprocess_error, "Searching for program", program);
606 program = Fexpand_file_name (tem, Qnil); 621 program = Fexpand_file_name (tem, Qnil);
607 NUNGCPRO; 622 NUNGCPRO;
608 } 623 }
609 else 624 else
610 { 625 {
615 tem = Qnil; 630 tem = Qnil;
616 NGCPRO1 (tem); 631 NGCPRO1 (tem);
617 locate_file (list1 (build_string ("")), program, Vlisp_EXEC_SUFFIXES, 632 locate_file (list1 (build_string ("")), program, Vlisp_EXEC_SUFFIXES,
618 &tem, X_OK); 633 &tem, X_OK);
619 if (NILP (tem)) 634 if (NILP (tem))
620 report_file_error ("Searching for program", list1 (program)); 635 signal_error (Qprocess_error, "Searching for program", program);
621 program = tem; 636 program = tem;
622 NUNGCPRO; 637 NUNGCPRO;
623 } 638 }
624 639
625 if (!NILP (Ffile_directory_p (program))) 640 if (!NILP (Ffile_directory_p (program)))
987 Lisp_Object lstream = Qnil; 1002 Lisp_Object lstream = Qnil;
988 1003
989 GCPRO2 (process, lstream); 1004 GCPRO2 (process, lstream);
990 1005
991 if (NILP (DATA_OUTSTREAM (XPROCESS (process)))) 1006 if (NILP (DATA_OUTSTREAM (XPROCESS (process))))
992 signal_simple_error ("Process not open for writing", process); 1007 invalid_operation ("Process not open for writing", process);
993 1008
994 if (nonrelocatable) 1009 if (nonrelocatable)
995 lstream = 1010 lstream =
996 make_fixed_buffer_input_stream (nonrelocatable + start, len); 1011 make_fixed_buffer_input_stream (nonrelocatable + start, len);
997 else if (BUFFERP (relocatable)) 1012 else if (BUFFERP (relocatable))
1689 handle_signal (SIGPWR); 1704 handle_signal (SIGPWR);
1690 #endif 1705 #endif
1691 1706
1692 #undef handle_signal 1707 #undef handle_signal
1693 1708
1694 error ("Undefined signal name %s", name); 1709 invalid_constant ("Undefined signal name", signal_);
1695 return 0; /* Unreached */ 1710 return 0; /* Unreached */
1696 } 1711 }
1697 } 1712 }
1698 1713
1699 /* Send signal number SIGNO to PROCESS. 1714 /* Send signal number SIGNO to PROCESS.
1715 { 1730 {
1716 /* This function can GC */ 1731 /* This function can GC */
1717 process = get_process (process); 1732 process = get_process (process);
1718 1733
1719 if (network_connection_p (process)) 1734 if (network_connection_p (process))
1720 error ("Network connection %s is not a subprocess", 1735 invalid_operation ("Network connection is not a subprocess", process);
1721 XSTRING_DATA (XPROCESS(process)->name));
1722 CHECK_LIVE_PROCESS (process); 1736 CHECK_LIVE_PROCESS (process);
1723 1737
1724 MAYBE_PROCMETH (kill_child_process, (process, signo, current_group, nomsg)); 1738 MAYBE_PROCMETH (kill_child_process, (process, signo, current_group, nomsg));
1725 } 1739 }
1726 1740
1762 { 1776 {
1763 /* This function can GC */ 1777 /* This function can GC */
1764 #ifdef SIGKILL 1778 #ifdef SIGKILL
1765 process_send_signal (process, SIGKILL, !NILP (current_group), 0); 1779 process_send_signal (process, SIGKILL, !NILP (current_group), 0);
1766 #else 1780 #else
1767 error ("kill-process: Not supported on this system"); 1781 signal_error (Qunimplemented,
1782 "kill-process: Not supported on this system",
1783 Qunbound);
1768 #endif 1784 #endif
1769 return process; 1785 return process;
1770 } 1786 }
1771 1787
1772 DEFUN ("quit-process", Fquit_process, 0, 2, 0, /* 1788 DEFUN ("quit-process", Fquit_process, 0, 2, 0, /*
1777 { 1793 {
1778 /* This function can GC */ 1794 /* This function can GC */
1779 #ifdef SIGQUIT 1795 #ifdef SIGQUIT
1780 process_send_signal (process, SIGQUIT, !NILP (current_group), 0); 1796 process_send_signal (process, SIGQUIT, !NILP (current_group), 0);
1781 #else 1797 #else
1782 error ("quit-process: Not supported on this system"); 1798 signal_error (Qunimplemented,
1799 "quit-process: Not supported on this system",
1800 Qunbound);
1783 #endif 1801 #endif
1784 return process; 1802 return process;
1785 } 1803 }
1786 1804
1787 DEFUN ("stop-process", Fstop_process, 0, 2, 0, /* 1805 DEFUN ("stop-process", Fstop_process, 0, 2, 0, /*
1792 { 1810 {
1793 /* This function can GC */ 1811 /* This function can GC */
1794 #ifdef SIGTSTP 1812 #ifdef SIGTSTP
1795 process_send_signal (process, SIGTSTP, !NILP (current_group), 0); 1813 process_send_signal (process, SIGTSTP, !NILP (current_group), 0);
1796 #else 1814 #else
1797 error ("stop-process: Not supported on this system"); 1815 signal_error (Qunimplemented,
1816 "stop-process: Not supported on this system",
1817 Qunbound);
1798 #endif 1818 #endif
1799 return process; 1819 return process;
1800 } 1820 }
1801 1821
1802 DEFUN ("continue-process", Fcontinue_process, 0, 2, 0, /* 1822 DEFUN ("continue-process", Fcontinue_process, 0, 2, 0, /*
1807 { 1827 {
1808 /* This function can GC */ 1828 /* This function can GC */
1809 #ifdef SIGCONT 1829 #ifdef SIGCONT
1810 process_send_signal (process, SIGCONT, !NILP (current_group), 0); 1830 process_send_signal (process, SIGCONT, !NILP (current_group), 0);
1811 #else 1831 #else
1812 error ("continue-process: Not supported on this system"); 1832 signal_error (Qunimplemented,
1833 "continue-process: Not supported on this system",
1834 Qunbound);
1813 #endif 1835 #endif
1814 return process; 1836 return process;
1815 } 1837 }
1816 1838
1817 DEFUN ("signal-process", Fsignal_process, 2, 2, 1839 DEFUN ("signal-process", Fsignal_process, 2, 2,
1842 /* This function can GC */ 1864 /* This function can GC */
1843 process = get_process (process); 1865 process = get_process (process);
1844 1866
1845 /* Make sure the process is really alive. */ 1867 /* Make sure the process is really alive. */
1846 if (! EQ (XPROCESS (process)->status_symbol, Qrun)) 1868 if (! EQ (XPROCESS (process)->status_symbol, Qrun))
1847 error ("Process %s not running", XSTRING_DATA (XPROCESS (process)->name)); 1869 invalid_operation ("Process not running", process);
1848 1870
1849 if (!MAYBE_INT_PROCMETH (process_send_eof, (process))) 1871 if (!MAYBE_INT_PROCMETH (process_send_eof, (process)))
1850 { 1872 {
1851 if (!NILP (DATA_OUTSTREAM (XPROCESS (process)))) 1873 if (!NILP (DATA_OUTSTREAM (XPROCESS (process))))
1852 { 1874 {
2021 void 2043 void
2022 syms_of_process (void) 2044 syms_of_process (void)
2023 { 2045 {
2024 INIT_LRECORD_IMPLEMENTATION (process); 2046 INIT_LRECORD_IMPLEMENTATION (process);
2025 2047
2026 defsymbol (&Qprocessp, "processp"); 2048 DEFSYMBOL (Qprocessp);
2027 defsymbol (&Qprocess_live_p, "process-live-p"); 2049 DEFSYMBOL (Qprocess_live_p);
2028 defsymbol (&Qrun, "run"); 2050 DEFSYMBOL (Qrun);
2029 defsymbol (&Qstop, "stop"); 2051 DEFSYMBOL (Qstop);
2030 defsymbol (&Qopen, "open"); 2052 DEFSYMBOL (Qopen);
2031 defsymbol (&Qclosed, "closed"); 2053 DEFSYMBOL (Qclosed);
2032 2054
2033 defsymbol (&Qtcp, "tcp"); 2055 DEFSYMBOL (Qtcp);
2034 defsymbol (&Qudp, "udp"); 2056 DEFSYMBOL (Qudp);
2035 2057
2036 #ifdef HAVE_MULTICAST 2058 #ifdef HAVE_MULTICAST
2037 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */ 2059 DEFSYMBOL (Qmulticast); /* Used for occasional warnings */
2038 #endif 2060 #endif
2061
2062 DEFERROR_STANDARD (Qprocess_error, Qio_error);
2063 DEFERROR_STANDARD (Qnetwork_error, Qio_error);
2039 2064
2040 DEFSUBR (Fprocessp); 2065 DEFSUBR (Fprocessp);
2041 DEFSUBR (Fprocess_live_p); 2066 DEFSUBR (Fprocess_live_p);
2042 DEFSUBR (Fget_process); 2067 DEFSUBR (Fget_process);
2043 DEFSUBR (Fget_buffer_process); 2068 DEFSUBR (Fget_buffer_process);