Mercurial > hg > xemacs-beta
comparison src/process-unix.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 | ed498ef2108b |
children | 6db80f4ab17c |
comparison
equal
deleted
inserted
replaced
562:c775bd016b32 | 563:183866b06e0b |
---|---|
477 IN_ADDR numeric_addr; | 477 IN_ADDR numeric_addr; |
478 /* Attempt to interpret host as numeric inet address */ | 478 /* Attempt to interpret host as numeric inet address */ |
479 numeric_addr = inet_addr ((char *) XSTRING_DATA (host)); | 479 numeric_addr = inet_addr ((char *) XSTRING_DATA (host)); |
480 if (NUMERIC_ADDR_ERROR) | 480 if (NUMERIC_ADDR_ERROR) |
481 { | 481 { |
482 maybe_error (Qprocess, errb, | 482 maybe_signal_error (Qio_error, "Unknown host", host, |
483 "Unknown host \"%s\"", XSTRING_DATA (host)); | 483 Qprocess, errb); |
484 return 0; | 484 return 0; |
485 } | 485 } |
486 | 486 |
487 /* There was some broken code here that called strlen() here | 487 /* There was some broken code here that called strlen() here |
488 on (char *) &numeric_addr and even sometimes accessed | 488 on (char *) &numeric_addr and even sometimes accessed |
1072 if (pid < 0) | 1072 if (pid < 0) |
1073 { | 1073 { |
1074 int save_errno = errno; | 1074 int save_errno = errno; |
1075 close_descriptor_pair (forkin, forkout); | 1075 close_descriptor_pair (forkin, forkout); |
1076 errno = save_errno; | 1076 errno = save_errno; |
1077 report_file_error ("Doing fork", Qnil); | 1077 report_process_error ("Doing fork", Qunbound); |
1078 } | 1078 } |
1079 | 1079 |
1080 /* #### dmoore - why is this commented out, otherwise we leave | 1080 /* #### dmoore - why is this commented out, otherwise we leave |
1081 subtty = forkin, but then we close forkin just below. */ | 1081 subtty = forkin, but then we close forkin just below. */ |
1082 /* UNIX_DATA(p)->subtty = -1; */ | 1082 /* UNIX_DATA(p)->subtty = -1; */ |
1102 { | 1102 { |
1103 int save_errno = errno; | 1103 int save_errno = errno; |
1104 close_descriptor_pair (forkin, forkout); | 1104 close_descriptor_pair (forkin, forkout); |
1105 close_descriptor_pair (inchannel, outchannel); | 1105 close_descriptor_pair (inchannel, outchannel); |
1106 errno = save_errno; | 1106 errno = save_errno; |
1107 report_file_error ("Opening pty or pipe", Qnil); | 1107 report_process_error ("Opening pty or pipe", Qunbound); |
1108 return 0; /* not reached */ | 1108 return 0; /* not reached */ |
1109 } | 1109 } |
1110 } | 1110 } |
1111 | 1111 |
1112 /* Return nonzero if this process is a ToolTalk connection. */ | 1112 /* Return nonzero if this process is a ToolTalk connection. */ |
1291 /* Lstream_write() will never successfully write less than | 1291 /* Lstream_write() will never successfully write less than |
1292 the amount sent in. In the worst case, it just buffers | 1292 the amount sent in. In the worst case, it just buffers |
1293 the unwritten data. */ | 1293 the unwritten data. */ |
1294 writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf, | 1294 writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf, |
1295 chunklen); | 1295 chunklen); |
1296 signal (SIGPIPE, old_sigpipe); | 1296 { |
1297 if (writeret < 0) | 1297 int save_errno = errno; |
1298 /* This is a real error. Blocking errors are handled | 1298 signal (SIGPIPE, old_sigpipe); |
1299 specially inside of the filedesc stream. */ | 1299 errno = save_errno; |
1300 report_file_error ("writing to process", list1 (proc)); | 1300 if (writeret < 0) |
1301 /* This is a real error. Blocking errors are handled | |
1302 specially inside of the filedesc stream. */ | |
1303 report_process_error ("writing to process", proc); | |
1304 } | |
1301 while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream))) | 1305 while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream))) |
1302 { | 1306 { |
1303 /* Buffer is full. Wait, accepting input; | 1307 /* Buffer is full. Wait, accepting input; |
1304 that may allow the program | 1308 that may allow the program |
1305 to finish doing output and read more. */ | 1309 to finish doing output and read more. */ |
1539 XPG 4.2 requires that killing a zombie fail with ESRCH, | 1543 XPG 4.2 requires that killing a zombie fail with ESRCH, |
1540 while FIPS 151-2 requires that it succeeds! */ | 1544 while FIPS 151-2 requires that it succeeds! */ |
1541 #ifdef ESRCH | 1545 #ifdef ESRCH |
1542 if (errno != ESRCH) | 1546 if (errno != ESRCH) |
1543 #endif | 1547 #endif |
1544 error ("kill (%ld, %ld) failed: %s", | 1548 signal_ferror_with_frob (Qio_error, lisp_strerror (errno), |
1545 (long) pgid, (long) signo, strerror (errno)); | 1549 "kill (pgid=%ld, signo=%ld) failed", |
1550 (long) pgid, (long) signo); | |
1546 } | 1551 } |
1547 } | 1552 } |
1548 | 1553 |
1549 /* Send signal SIGCODE to any process in the system given its PID. | 1554 /* Send signal SIGCODE to any process in the system given its PID. |
1550 Return zero if successful, a negative number upon failure. */ | 1555 Return zero if successful, a negative number upon failure. */ |
1584 hints.ai_protocol = 0; | 1589 hints.ai_protocol = 0; |
1585 LISP_STRING_TO_EXTERNAL (host, ext_host, Qnative); | 1590 LISP_STRING_TO_EXTERNAL (host, ext_host, Qnative); |
1586 retval = getaddrinfo (ext_host, NULL, &hints, &res); | 1591 retval = getaddrinfo (ext_host, NULL, &hints, &res); |
1587 if (retval != 0) | 1592 if (retval != 0) |
1588 { | 1593 { |
1589 char *gai_error; | 1594 Bufbyte *gai_error; |
1590 | 1595 |
1591 EXTERNAL_TO_C_STRING (gai_strerror (retval), gai_error, Qnative); | 1596 EXTERNAL_TO_C_STRING (gai_strerror (retval), gai_error, Qnative); |
1592 maybe_error (Qprocess, ERROR_ME_NOT, | 1597 maybe_signal_error (Qio_error, gai_error, host, |
1593 "%s \"%s\"", gai_error, XSTRING_DATA (host)); | 1598 Qprocess, ERROR_ME_NOT); |
1594 canonname = host; | 1599 canonname = host; |
1595 } | 1600 } |
1596 else | 1601 else |
1597 { | 1602 { |
1598 int gni = getnameinfo (res->ai_addr, res->ai_addrlen, | 1603 int gni = getnameinfo (res->ai_addr, res->ai_addrlen, |
1639 int retval; | 1644 int retval; |
1640 | 1645 |
1641 CHECK_STRING (host); | 1646 CHECK_STRING (host); |
1642 | 1647 |
1643 if (!EQ (protocol, Qtcp) && !EQ (protocol, Qudp)) | 1648 if (!EQ (protocol, Qtcp) && !EQ (protocol, Qudp)) |
1644 invalid_argument ("Unsupported protocol", protocol); | 1649 invalid_constant ("Unsupported protocol", protocol); |
1645 | 1650 |
1646 { | 1651 { |
1647 #ifdef USE_GETADDRINFO | 1652 #ifdef USE_GETADDRINFO |
1648 | 1653 |
1649 struct addrinfo hints, *res; | 1654 struct addrinfo hints, *res; |
1678 hints.ai_protocol = 0; | 1683 hints.ai_protocol = 0; |
1679 LISP_STRING_TO_EXTERNAL (host, ext_host, Qnative); | 1684 LISP_STRING_TO_EXTERNAL (host, ext_host, Qnative); |
1680 retval = getaddrinfo (ext_host, portstring, &hints, &res); | 1685 retval = getaddrinfo (ext_host, portstring, &hints, &res); |
1681 if (retval != 0) | 1686 if (retval != 0) |
1682 { | 1687 { |
1683 char *gai_error; | 1688 Bufbyte *gai_error; |
1684 | 1689 |
1685 EXTERNAL_TO_C_STRING (gai_strerror (retval), gai_error, Qnative); | 1690 EXTERNAL_TO_C_STRING (gai_strerror (retval), gai_error, Qnative); |
1686 error ("%s/%s %s", XSTRING_DATA (host), portstring, gai_error); | 1691 signal_error (Qio_error, gai_error, list2 (host, service)); |
1687 } | 1692 } |
1688 | 1693 |
1689 /* address loop */ | 1694 /* address loop */ |
1690 for (lres = res; lres ; lres = lres->ai_next) | 1695 for (lres = res; lres ; lres = lres->ai_next) |
1691 | 1696 |
1846 if (s < 0) | 1851 if (s < 0) |
1847 { | 1852 { |
1848 errno = xerrno; | 1853 errno = xerrno; |
1849 | 1854 |
1850 if (failed_connect) | 1855 if (failed_connect) |
1851 report_file_error ("connection failed", list2 (host, name)); | 1856 report_network_error ("connection failed", list3 (Qunbound, host, |
1857 name)); | |
1852 else | 1858 else |
1853 report_file_error ("error creating socket", list1 (name)); | 1859 report_network_error ("error creating socket", name); |
1854 } | 1860 } |
1855 } | 1861 } |
1856 | 1862 |
1857 inch = s; | 1863 inch = s; |
1858 outch = dup (s); | 1864 outch = dup (s); |
1859 if (outch < 0) | 1865 if (outch < 0) |
1860 { | 1866 { |
1867 int save_errno = errno; | |
1861 close (s); /* this used to be leaked; from Kyle Jones */ | 1868 close (s); /* this used to be leaked; from Kyle Jones */ |
1862 report_file_error ("error duplicating socket", list1 (name)); | 1869 errno = save_errno; |
1870 report_network_error ("error duplicating socket", name); | |
1863 } | 1871 } |
1864 | 1872 |
1865 set_socket_nonblocking_maybe (inch, port, "tcp"); | 1873 set_socket_nonblocking_maybe (inch, port, "tcp"); |
1866 | 1874 |
1867 *vinfd = (void *) inch; | 1875 *vinfd = (void *) inch; |
1911 | 1919 |
1912 CHECK_NATNUM (ttl); | 1920 CHECK_NATNUM (ttl); |
1913 thettl = (unsigned char) XINT (ttl); | 1921 thettl = (unsigned char) XINT (ttl); |
1914 | 1922 |
1915 if ((udp = getprotobyname ("udp")) == NULL) | 1923 if ((udp = getprotobyname ("udp")) == NULL) |
1916 type_error (Qinvalid_operation, "No info available for UDP protocol"); | 1924 invalid_operation ("No info available for UDP protocol", Qunbound); |
1917 | 1925 |
1918 /* Init the sockets. Yes, I need 2 sockets. I couldn't duplicate one. */ | 1926 /* Init the sockets. Yes, I need 2 sockets. I couldn't duplicate one. */ |
1919 if ((rs = socket (PF_INET, SOCK_DGRAM, udp->p_proto)) < 0) | 1927 if ((rs = socket (PF_INET, SOCK_DGRAM, udp->p_proto)) < 0) |
1920 report_file_error ("error creating socket", list1(name)); | 1928 report_network_error ("error creating socket", name); |
1921 if ((ws = socket (PF_INET, SOCK_DGRAM, udp->p_proto)) < 0) | 1929 if ((ws = socket (PF_INET, SOCK_DGRAM, udp->p_proto)) < 0) |
1922 { | 1930 { |
1931 int save_errno = errno; | |
1923 close (rs); | 1932 close (rs); |
1924 report_file_error ("error creating socket", list1(name)); | 1933 errno = save_errno; |
1934 report_network_error ("error creating socket", name); | |
1925 } | 1935 } |
1926 | 1936 |
1927 /* This will be used for both sockets */ | 1937 /* This will be used for both sockets */ |
1928 memset (&sa, 0, sizeof(sa)); | 1938 memset (&sa, 0, sizeof(sa)); |
1929 sa.sin_family = AF_INET; | 1939 sa.sin_family = AF_INET; |
1940 warn_when_safe (Qmulticast, Qwarning, "Cannot reuse socket address"); | 1950 warn_when_safe (Qmulticast, Qwarning, "Cannot reuse socket address"); |
1941 | 1951 |
1942 /* bind socket name */ | 1952 /* bind socket name */ |
1943 if (bind (rs, (struct sockaddr *)&sa, sizeof(sa))) | 1953 if (bind (rs, (struct sockaddr *)&sa, sizeof(sa))) |
1944 { | 1954 { |
1955 int save_errno = errno; | |
1945 close (rs); | 1956 close (rs); |
1946 close (ws); | 1957 close (ws); |
1947 report_file_error ("error binding socket", list2(name, port)); | 1958 errno = save_errno; |
1959 report_network_error ("error binding socket", list3 (Qunbound, name, | |
1960 port)); | |
1948 } | 1961 } |
1949 | 1962 |
1950 /* join multicast group */ | 1963 /* join multicast group */ |
1951 imr.imr_multiaddr.s_addr = htonl (inet_addr ((char *) XSTRING_DATA (dest))); | 1964 imr.imr_multiaddr.s_addr = htonl (inet_addr ((char *) XSTRING_DATA (dest))); |
1952 imr.imr_interface.s_addr = htonl (INADDR_ANY); | 1965 imr.imr_interface.s_addr = htonl (INADDR_ANY); |
1953 if (setsockopt (rs, IPPROTO_IP, IP_ADD_MEMBERSHIP, | 1966 if (setsockopt (rs, IPPROTO_IP, IP_ADD_MEMBERSHIP, |
1954 &imr, sizeof (struct ip_mreq)) < 0) | 1967 &imr, sizeof (struct ip_mreq)) < 0) |
1955 { | 1968 { |
1969 int save_errno = errno; | |
1956 close (ws); | 1970 close (ws); |
1957 close (rs); | 1971 close (rs); |
1958 report_file_error ("error adding membership", list2(name, dest)); | 1972 errno = save_errno; |
1973 report_network_error ("error adding membership", list3 (Qunbound, name, | |
1974 dest)); | |
1959 } | 1975 } |
1960 | 1976 |
1961 /* Socket configuration for writing ----------------------- */ | 1977 /* Socket configuration for writing ----------------------- */ |
1962 | 1978 |
1963 /* Normally, there's no 'connect' in multicast, since we prefer to use | 1979 /* Normally, there's no 'connect' in multicast, since we prefer to use |
2016 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS | 2032 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS |
2017 speed_up_interrupts (); | 2033 speed_up_interrupts (); |
2018 #endif | 2034 #endif |
2019 | 2035 |
2020 errno = xerrno; | 2036 errno = xerrno; |
2021 report_file_error ("error connecting socket", list2(name, port)); | 2037 report_network_error ("error connecting socket", list3 (Qunbound, name, |
2038 port)); | |
2022 } | 2039 } |
2023 | 2040 |
2024 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS | 2041 #ifdef CONNECT_NEEDS_SLOWED_INTERRUPTS |
2025 speed_up_interrupts (); | 2042 speed_up_interrupts (); |
2026 #endif | 2043 #endif |
2027 | 2044 |
2028 /* scope */ | 2045 /* scope */ |
2029 if (setsockopt (ws, IPPROTO_IP, IP_MULTICAST_TTL, | 2046 if (setsockopt (ws, IPPROTO_IP, IP_MULTICAST_TTL, |
2030 &thettl, sizeof (thettl)) < 0) | 2047 &thettl, sizeof (thettl)) < 0) |
2031 { | 2048 { |
2049 int save_errno = errno; | |
2032 close (rs); | 2050 close (rs); |
2033 close (ws); | 2051 close (ws); |
2034 report_file_error ("error setting ttl", list2(name, ttl)); | 2052 errno = save_errno; |
2053 report_network_error ("error setting ttl", list3 (Qunbound, name, ttl)); | |
2035 } | 2054 } |
2036 | 2055 |
2037 set_socket_nonblocking_maybe (rs, theport, "udp"); | 2056 set_socket_nonblocking_maybe (rs, theport, "udp"); |
2038 | 2057 |
2039 *vinfd = (void*)rs; | 2058 *vinfd = (void*)rs; |