end of the ptys. */
int failed_count = 0;
#endif
- int i;
int fd;
+#ifndef HAVE_GETPT
+ int i;
int c;
+#endif
#ifdef PTY_ITERATION
PTY_ITERATION
#else
sprintf (pty_name, "/dev/tty%c%x", c, i);
#endif /* no PTY_TTY_NAME_SPRINTF */
-#ifndef UNIPLUS
+#if !defined(UNIPLUS) && !defined(HAVE_GETPT)
if (access (pty_name, 6) != 0)
{
close (fd);
else
continue;
}
- else if ((INTP (tail_port)) && (htons ((unsigned short) XINT (tail_port)) == port))
+ else if (INTP (tail_port) && (htons ((unsigned short) XINT (tail_port)) == port))
break;
}
*/
static void
-unix_mark_process_data (struct Lisp_Process *proc,
- void (*markobj) (Lisp_Object))
+unix_mark_process_data (struct Lisp_Process *proc)
{
- markobj (UNIX_DATA(proc)->tty_name);
+ mark_object (UNIX_DATA(proc)->tty_name);
}
/*
}
/*
- * Fork off a subprocess. P is a pointer to newly created subprocess
+ * Fork off a subprocess. P is a pointer to a newly created subprocess
* object. If this function signals, the caller is responsible for
* deleting (and finalizing) the process object.
*
{
/* This function rewritten by ben@xemacs.org. */
- int pid, inchannel, outchannel;
+ int pid;
+ int inchannel = -1;
+ int outchannel = -1;
/* Use volatile to protect variables from being clobbered by longjmp. */
- volatile int forkin, forkout;
+ volatile int forkin = -1;
+ volatile int forkout = -1;
volatile int pty_flag = 0;
- char **env;
- char **new_argv;
- char *current_dir;
- int i;
-
- env = environ;
-
- inchannel = outchannel = forkin = forkout = -1;
-
- /* Nothing below here GCs so our string pointers shouldn't move. */
- new_argv = alloca_array (char *, nargv + 2);
- GET_C_STRING_FILENAME_DATA_ALLOCA (program, new_argv[0]);
- for (i = 0; i < nargv; i++)
- {
- Lisp_Object tem = argv[i];
- CHECK_STRING (tem);
- new_argv[i + 1] = (char *) XSTRING_DATA (tem);
- }
- new_argv[i + 1] = 0;
- GET_C_STRING_FILENAME_DATA_ALLOCA (cur_dir, current_dir);
#ifdef HAVE_PTYS
if (!NILP (Vprocess_connection_type))
better error checking. */
#if !defined(USG)
/* On USG systems it does not work to open the pty's tty here
- and then close and reopen it in the child. */
+ and then close and reopen it in the child. */
#ifdef O_NOCTTY
/* Don't let this terminal become our controlling terminal
(in case we don't have one). */
*/
signal (SIGHUP, SIG_DFL);
}
+
+ if (pty_flag)
+ /* Set up the terminal characteristics of the pty. */
+ child_setup_tty (xforkout);
+
#endif /* HAVE_PTYS */
- signal (SIGINT, SIG_DFL);
+ signal (SIGINT, SIG_DFL);
signal (SIGQUIT, SIG_DFL);
- if (pty_flag)
- {
- /* Set up the terminal characteristics of the pty. */
- child_setup_tty (xforkout);
- }
+ {
+ char *current_dir;
+ char **new_argv = alloca_array (char *, nargv + 2);
+ int i;
- child_setup (xforkin, xforkout, xforkout, new_argv, current_dir);
- }
+ /* Nothing below here GCs so our string pointers shouldn't move. */
+ new_argv[0] = (char *) XSTRING_DATA (program);
+ for (i = 0; i < nargv; i++)
+ {
+ CHECK_STRING (argv[i]);
+ new_argv[i + 1] = (char *) XSTRING_DATA (argv[i]);
+ }
+ new_argv[i + 1] = 0;
+
+ GET_C_STRING_FILENAME_DATA_ALLOCA (cur_dir, current_dir);
+
+ child_setup (xforkin, xforkout, xforkout, new_argv, current_dir);
+ }
+
+ } /**** End of child code ****/
+ /**** Back in parent process ****/
#if !defined(__CYGWIN32__)
environ = save_environ;
#endif
io_failure:
{
- int temp = errno;
+ int save_errno = errno;
close_descriptor_pair (forkin, forkout);
close_descriptor_pair (inchannel, outchannel);
- errno = temp;
+ errno = save_errno;
report_file_error ("Opening pty or pipe", Qnil);
+ return 0; /* not reached */
}
-
- RETURN_NOT_REACHED (0);
}
/* Return nonzero if this process is a ToolTalk connection. */
while (1)
{
- int writeret;
+ ssize_t writeret;
chunklen = Lstream_read (lstream, chunkbuf, 512);
if (chunklen <= 0)
static void
unix_open_network_stream (Lisp_Object name, Lisp_Object host, Lisp_Object service,
- Lisp_Object family, void** vinfd, void** voutfd)
+ Lisp_Object protocol, void** vinfd, void** voutfd)
{
struct sockaddr_in address;
- int s, inch, outch;
+ int inch;
+ int outch;
+ volatile int s;
volatile int port;
volatile int retry = 0;
int retval;
CHECK_STRING (host);
- if (!EQ (family, Qtcpip))
- error ("Unsupported protocol family \"%s\"",
- string_data (symbol_name (XSYMBOL (family))));
+ if (!EQ (protocol, Qtcp) && !EQ (protocol, Qudp))
+ error ("Unsupported protocol \"%s\"",
+ string_data (symbol_name (XSYMBOL (protocol))));
if (INTP (service))
port = htons ((unsigned short) XINT (service));
{
struct servent *svc_info;
CHECK_STRING (service);
- svc_info = getservbyname ((char *) XSTRING_DATA (service), "tcp");
+
+ if (EQ (protocol, Qtcp))
+ svc_info = getservbyname ((char *) XSTRING_DATA (service), "tcp");
+ else /* EQ (protocol, Qudp) */
+ svc_info = getservbyname ((char *) XSTRING_DATA (service), "udp");
+
if (svc_info == 0)
error ("Unknown service \"%s\"", XSTRING_DATA (service));
port = svc_info->s_port;
get_internet_address (host, &address, ERROR_ME);
address.sin_port = port;
- s = socket (address.sin_family, SOCK_STREAM, 0);
+ if (EQ (protocol, Qtcp))
+ s = socket (address.sin_family, SOCK_STREAM, 0);
+ else /* EQ (protocol, Qudp) */
+ s = socket (address.sin_family, SOCK_DGRAM, 0);
+
if (s < 0)
report_file_error ("error creating socket", list1 (name));