comparison src/process.c @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 15872534500d
children 2d532a89d707
comparison
equal deleted inserted replaced
172:a38aed19690b 173:8eaf7971accc
214 ((markobj) (proc->pid)); 214 ((markobj) (proc->pid));
215 ((markobj) (proc->tty_name)); 215 ((markobj) (proc->tty_name));
216 ((markobj) (proc->instream)); 216 ((markobj) (proc->instream));
217 ((markobj) (proc->outstream)); 217 ((markobj) (proc->outstream));
218 ((markobj) (proc->filedesc_stream)); 218 ((markobj) (proc->filedesc_stream));
219 return (proc->status_symbol); 219 return proc->status_symbol;
220 } 220 }
221 221
222 static void 222 static void
223 print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 223 print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
224 { 224 {
357 357
358 #ifdef HAVE_SOCKETS 358 #ifdef HAVE_SOCKETS
359 int 359 int
360 network_connection_p (Lisp_Object process) 360 network_connection_p (Lisp_Object process)
361 { 361 {
362 return (GC_CONSP (XPROCESS (process)->pid)); 362 return GC_CONSP (XPROCESS (process)->pid);
363 } 363 }
364 #endif 364 #endif
365 365
366 int 366 int
367 connected_via_filedesc_p (struct Lisp_Process *p) 367 connected_via_filedesc_p (struct Lisp_Process *p)
372 DEFUN ("processp", Fprocessp, 1, 1, 0, /* 372 DEFUN ("processp", Fprocessp, 1, 1, 0, /*
373 Return t if OBJECT is a process. 373 Return t if OBJECT is a process.
374 */ 374 */
375 (obj)) 375 (obj))
376 { 376 {
377 return ((PROCESSP (obj)) ? Qt : Qnil); 377 return PROCESSP (obj) ? Qt : Qnil;
378 } 378 }
379 379
380 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /* 380 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /*
381 Return a list of all processes. 381 Return a list of all processes.
382 */ 382 */
391 (name)) 391 (name))
392 { 392 {
393 Lisp_Object tail; 393 Lisp_Object tail;
394 394
395 if (GC_PROCESSP (name)) 395 if (GC_PROCESSP (name))
396 return (name); 396 return name;
397 397
398 if (!gc_in_progress) 398 if (!gc_in_progress)
399 /* this only gets called during GC when emacs is going away as a result 399 /* this only gets called during GC when emacs is going away as a result
400 of a signal or crash. */ 400 of a signal or crash. */
401 CHECK_STRING (name); 401 CHECK_STRING (name);
403 for (tail = Vprocess_list; GC_CONSP (tail); tail = XCDR (tail)) 403 for (tail = Vprocess_list; GC_CONSP (tail); tail = XCDR (tail))
404 { 404 {
405 Lisp_Object proc = XCAR (tail); 405 Lisp_Object proc = XCAR (tail);
406 QUIT; 406 QUIT;
407 if (!NILP (Fequal (name, XPROCESS (proc)->name))) 407 if (!NILP (Fequal (name, XPROCESS (proc)->name)))
408 return (XCAR (tail)); 408 return XCAR (tail);
409 } 409 }
410 return Qnil; 410 return Qnil;
411 } 411 }
412 412
413 DEFUN ("get-buffer-process", Fget_buffer_process, 1, 1, 0, /* 413 DEFUN ("get-buffer-process", Fget_buffer_process, 1, 1, 0, /*
501 Lisp_Object pid; 501 Lisp_Object pid;
502 CHECK_PROCESS (proc); 502 CHECK_PROCESS (proc);
503 503
504 pid = XPROCESS (proc)->pid; 504 pid = XPROCESS (proc)->pid;
505 if (network_connection_p (proc)) 505 if (network_connection_p (proc))
506 /* return (Qnil); */ 506 /* return Qnil; */
507 return (Fcons (Fcar (pid), Fcdr (pid))); 507 return Fcons (Fcar (pid), Fcdr (pid));
508 else 508 else
509 return (pid); 509 return pid;
510 } 510 }
511 511
512 DEFUN ("process-name", Fprocess_name, 1, 1, 0, /* 512 DEFUN ("process-name", Fprocess_name, 1, 1, 0, /*
513 Return the name of PROCESS, as a string. 513 Return the name of PROCESS, as a string.
514 This is the name of the program invoked in PROCESS, 514 This is the name of the program invoked in PROCESS,
582 p->outstream = Qnil; 582 p->outstream = Qnil;
583 583
584 XSETPROCESS (val, p); 584 XSETPROCESS (val, p);
585 585
586 Vprocess_list = Fcons (val, Vprocess_list); 586 Vprocess_list = Fcons (val, Vprocess_list);
587 return (val); 587 return val;
588 } 588 }
589 589
590 #ifdef HAVE_PTYS 590 #ifdef HAVE_PTYS
591 591
592 /* Open an available pty, returning a file descriptor. 592 /* Open an available pty, returning a file descriptor.
1301 1301
1302 static int 1302 static int
1303 get_internet_address (Lisp_Object host, struct sockaddr_in *address, 1303 get_internet_address (Lisp_Object host, struct sockaddr_in *address,
1304 Error_behavior errb) 1304 Error_behavior errb)
1305 { 1305 {
1306 struct hostent *host_info_ptr; 1306 struct hostent *host_info_ptr = NULL;
1307 #ifdef TRY_AGAIN 1307 #ifdef TRY_AGAIN
1308 int count = 0; 1308 int count = 0;
1309 #endif 1309 #endif
1310 1310
1311 #ifndef HAVE_TERM 1311 #ifndef HAVE_TERM
1645 1645
1646 vs = get_vms_process_pointer (XINT (p->pid)); 1646 vs = get_vms_process_pointer (XINT (p->pid));
1647 if (vs) 1647 if (vs)
1648 { 1648 {
1649 if (!vs->iosb[0]) 1649 if (!vs->iosb[0])
1650 return(0); /* Really weird if it does this */ 1650 return 0; /* Really weird if it does this */
1651 if (!(vs->iosb[0] & 1)) 1651 if (!(vs->iosb[0] & 1))
1652 return -1; /* I/O error */ 1652 return -1; /* I/O error */
1653 } 1653 }
1654 else 1654 else
1655 error ("Could not get VMS process pointer"); 1655 error ("Could not get VMS process pointer");
1703 running_asynch_code = 0; 1703 running_asynch_code = 0;
1704 restore_match_data (); 1704 restore_match_data ();
1705 #ifdef VMS 1705 #ifdef VMS
1706 start_vms_process_read (vs); 1706 start_vms_process_read (vs);
1707 #endif 1707 #endif
1708 return (nchars); 1708 return nchars;
1709 } 1709 }
1710 1710
1711 /* If no filter, write into buffer if it isn't dead. */ 1711 /* If no filter, write into buffer if it isn't dead. */
1712 if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) 1712 if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
1713 { 1713 {
1794 UNGCPRO; 1794 UNGCPRO;
1795 } 1795 }
1796 #ifdef VMS 1796 #ifdef VMS
1797 start_vms_process_read (vs); 1797 start_vms_process_read (vs);
1798 #endif 1798 #endif
1799 return (nchars); 1799 return nchars;
1800 } 1800 }
1801 1801
1802 /* Sending data to subprocess */ 1802 /* Sending data to subprocess */
1803 1803
1804 static JMP_BUF send_process_frame; 1804 static JMP_BUF send_process_frame;
2029 2029
2030 get_buffer_range_char (current_buffer, start, end, &st, &en, 0); 2030 get_buffer_range_char (current_buffer, start, end, &st, &en, 0);
2031 2031
2032 send_process (proc, Fcurrent_buffer (), 0, 2032 send_process (proc, Fcurrent_buffer (), 0,
2033 st, en - st); 2033 st, en - st);
2034 return (Qnil); 2034 return Qnil;
2035 } 2035 }
2036 2036
2037 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /* 2037 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /*
2038 Send PROCESS the contents of STRING as input. 2038 Send PROCESS the contents of STRING as input.
2039 PROCESS may be a process name or an actual process. 2039 PROCESS may be a process name or an actual process.
2054 get_string_range_byte (string, from, to, &bfr, &bto, 2054 get_string_range_byte (string, from, to, &bfr, &bto,
2055 GB_HISTORICAL_STRING_BEHAVIOR); 2055 GB_HISTORICAL_STRING_BEHAVIOR);
2056 len = bto - bfr; 2056 len = bto - bfr;
2057 2057
2058 send_process (proc, string, 0, bfr, len); 2058 send_process (proc, string, 0, bfr, len);
2059 return (Qnil); 2059 return Qnil;
2060 } 2060 }
2061 2061
2062 #ifdef MULE 2062 #ifdef MULE
2063 2063
2064 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /* 2064 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /*
2205 CONST char * 2205 CONST char *
2206 signal_name (int signum) 2206 signal_name (int signum)
2207 { 2207 {
2208 if (signum >= 0 && signum < NSIG) 2208 if (signum >= 0 && signum < NSIG)
2209 #ifndef VMS 2209 #ifndef VMS
2210 return ((CONST char *) sys_siglist[signum]); 2210 return (CONST char *) sys_siglist[signum];
2211 #else 2211 #else
2212 return ((CONST char *) sys_errlist[signum]); 2212 return (CONST char *) sys_errlist[signum];
2213 #endif 2213 #endif
2214 return ((CONST char *) GETTEXT ("unknown signal")); 2214 return (CONST char *) GETTEXT ("unknown signal");
2215 } 2215 }
2216 2216
2217 /* Compute the Lisp form of the process status from 2217 /* Compute the Lisp form of the process status from
2218 the numeric status that was returned by `wait'. */ 2218 the numeric status that was returned by `wait'. */
2219 2219
2698 if (EQ (status, Qrun)) 2698 if (EQ (status, Qrun))
2699 status = Qopen; 2699 status = Qopen;
2700 else if (EQ (status, Qexit)) 2700 else if (EQ (status, Qexit))
2701 status = Qclosed; 2701 status = Qclosed;
2702 } 2702 }
2703 return (status); 2703 return status;
2704 } 2704 }
2705 2705
2706 DEFUN ("process-exit-status", Fprocess_exit_status, 1, 1, 0, /* 2706 DEFUN ("process-exit-status", Fprocess_exit_status, 1, 1, 0, /*
2707 Return the exit status of PROCESS or the signal number that killed it. 2707 Return the exit status of PROCESS or the signal number that killed it.
2708 If PROCESS has not yet exited or died, return 0. 2708 If PROCESS has not yet exited or died, return 0.
2709 */ 2709 */
2710 (proc)) 2710 (proc))
2711 { 2711 {
2712 CHECK_PROCESS (proc); 2712 CHECK_PROCESS (proc);
2713 return (make_int (XPROCESS (proc)->exit_code)); 2713 return make_int (XPROCESS (proc)->exit_code);
2714 } 2714 }
2715 2715
2716 2716
2717 #ifdef SIGNALS_VIA_CHARACTERS 2717 #ifdef SIGNALS_VIA_CHARACTERS
2718 /* Get signal character to send to process if SIGNALS_VIA_CHARACTERS */ 2718 /* Get signal character to send to process if SIGNALS_VIA_CHARACTERS */
3314 3314
3315 CHECK_PROCESS (proc); 3315 CHECK_PROCESS (proc);
3316 tem = XPROCESS (proc)->kill_without_query; 3316 tem = XPROCESS (proc)->kill_without_query;
3317 XPROCESS (proc)->kill_without_query = NILP (require_query_p); 3317 XPROCESS (proc)->kill_without_query = NILP (require_query_p);
3318 3318
3319 return (tem ? Qnil : Qt); 3319 return tem ? Qnil : Qt;
3320 } 3320 }
3321 3321
3322 DEFUN ("process-kill-without-query-p", Fprocess_kill_without_query_p, 1, 1, 0, /* 3322 DEFUN ("process-kill-without-query-p", Fprocess_kill_without_query_p, 1, 1, 0, /*
3323 Whether PROC will be killed without query if running when emacs is exited. 3323 Whether PROC will be killed without query if running when emacs is exited.
3324 */ 3324 */
3325 (proc)) 3325 (proc))
3326 { 3326 {
3327 CHECK_PROCESS (proc); 3327 CHECK_PROCESS (proc);
3328 return (XPROCESS (proc)->kill_without_query ? Qt : Qnil); 3328 return XPROCESS (proc)->kill_without_query ? Qt : Qnil;
3329 } 3329 }
3330 3330
3331 3331
3332 /* This is not named init_process in order to avoid a conflict with NS 3.3 */ 3332 /* This is not named init_process in order to avoid a conflict with NS 3.3 */
3333 void 3333 void