diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/src/process.c b/src/process.c index 90a5a2f5114..7bd40ad685e 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3441,10 +3441,49 @@ Output from processes can arrive in between bunches.") | |||
| 3441 | return Qnil; | 3441 | return Qnil; |
| 3442 | } | 3442 | } |
| 3443 | 3443 | ||
| 3444 | DEFUN ("process-running-child-p", Fprocess_running_child_p, | ||
| 3445 | Sprocess_running_child_p, 0, 1, 0, | ||
| 3446 | "Return t if PROCESS has given the terminal to a child.\n\ | ||
| 3447 | If the operating system does not make it possible to find out,\n\ | ||
| 3448 | return t unconditionally.") | ||
| 3449 | (process) | ||
| 3450 | Lisp_Object process; | ||
| 3451 | { | ||
| 3452 | /* Initialize in case ioctl doesn't exist or gives an error, | ||
| 3453 | in a way that will cause returning t. */ | ||
| 3454 | int gid = 0; | ||
| 3455 | Lisp_Object proc; | ||
| 3456 | struct Lisp_Process *p; | ||
| 3457 | |||
| 3458 | proc = get_process (process); | ||
| 3459 | p = XPROCESS (proc); | ||
| 3460 | |||
| 3461 | if (!EQ (p->childp, Qt)) | ||
| 3462 | error ("Process %s is not a subprocess", | ||
| 3463 | XSTRING (p->name)->data); | ||
| 3464 | if (XINT (p->infd) < 0) | ||
| 3465 | error ("Process %s is not active", | ||
| 3466 | XSTRING (p->name)->data); | ||
| 3467 | |||
| 3468 | #ifdef TIOCGPGRP | ||
| 3469 | if (!NILP (p->subtty)) | ||
| 3470 | ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); | ||
| 3471 | else | ||
| 3472 | ioctl (XINT (p->infd), TIOCGPGRP, &gid); | ||
| 3473 | #endif /* defined (TIOCGPGRP ) */ | ||
| 3474 | |||
| 3475 | if (gid == XFASTINT (p->pid)) | ||
| 3476 | return Qnil; | ||
| 3477 | return Qt; | ||
| 3478 | } | ||
| 3479 | |||
| 3444 | /* send a signal number SIGNO to PROCESS. | 3480 | /* send a signal number SIGNO to PROCESS. |
| 3445 | CURRENT_GROUP means send to the process group that currently owns | 3481 | If CURRENT_GROUP is t, that means send to the process group |
| 3446 | the terminal being used to communicate with PROCESS. | 3482 | that currently owns the terminal being used to communicate with PROCESS. |
| 3447 | This is used for various commands in shell mode. | 3483 | This is used for various commands in shell mode. |
| 3484 | If CURRENT_GROUP is lambda, that means send to the process group | ||
| 3485 | that currently owns the terminal, but only if it is NOT the shell itself. | ||
| 3486 | |||
| 3448 | If NOMSG is zero, insert signal-announcements into process's buffers | 3487 | If NOMSG is zero, insert signal-announcements into process's buffers |
| 3449 | right away. | 3488 | right away. |
| 3450 | 3489 | ||
| @@ -3600,6 +3639,11 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 3600 | the child itself heads the pgrp. */ | 3639 | the child itself heads the pgrp. */ |
| 3601 | gid = - XFASTINT (p->pid); | 3640 | gid = - XFASTINT (p->pid); |
| 3602 | #endif /* ! defined (TIOCGPGRP ) */ | 3641 | #endif /* ! defined (TIOCGPGRP ) */ |
| 3642 | |||
| 3643 | /* If current_group is lambda, and the shell owns the terminal, | ||
| 3644 | don't send any signal. */ | ||
| 3645 | if (EQ (current_group, Qlambda) && gid == - XFASTINT (p->pid)) | ||
| 3646 | return; | ||
| 3603 | } | 3647 | } |
| 3604 | else | 3648 | else |
| 3605 | gid = - XFASTINT (p->pid); | 3649 | gid = - XFASTINT (p->pid); |
| @@ -3666,7 +3710,10 @@ Second arg CURRENT-GROUP non-nil means send signal to\n\ | |||
| 3666 | the current process-group of the process's controlling terminal\n\ | 3710 | the current process-group of the process's controlling terminal\n\ |
| 3667 | rather than to the process's own process group.\n\ | 3711 | rather than to the process's own process group.\n\ |
| 3668 | If the process is a shell, this means interrupt current subjob\n\ | 3712 | If the process is a shell, this means interrupt current subjob\n\ |
| 3669 | rather than the shell.") | 3713 | rather than the shell.\n\ |
| 3714 | \n\ | ||
| 3715 | If CURRENT-GROUP is `lambda', and if the shell owns the terminal,\n\ | ||
| 3716 | don't send the signal.") | ||
| 3670 | (process, current_group) | 3717 | (process, current_group) |
| 3671 | Lisp_Object process, current_group; | 3718 | Lisp_Object process, current_group; |
| 3672 | { | 3719 | { |
| @@ -4539,6 +4586,7 @@ The value takes effect when `start-process' is called."); | |||
| 4539 | defsubr (&Squit_process); | 4586 | defsubr (&Squit_process); |
| 4540 | defsubr (&Sstop_process); | 4587 | defsubr (&Sstop_process); |
| 4541 | defsubr (&Scontinue_process); | 4588 | defsubr (&Scontinue_process); |
| 4589 | defsubr (&Sprocess_running_child_p); | ||
| 4542 | defsubr (&Sprocess_send_eof); | 4590 | defsubr (&Sprocess_send_eof); |
| 4543 | defsubr (&Ssignal_process); | 4591 | defsubr (&Ssignal_process); |
| 4544 | defsubr (&Swaiting_for_user_input_p); | 4592 | defsubr (&Swaiting_for_user_input_p); |