On my system,
yes doesn't react to
SIGTSTP, which is the signal sent by
stop-process (rather than
SIGSTOP as one might assume).
When you run
yes in your terminal and shell,
C-z is going to additionally prevent the process from having a terminal to write to -- so if the process is still running and generating output, the kernel will stop it at that point (via
SIGTTOU as I understand it). My guess is that that's the difference between the two scenarios.
You can use
(signal-process ptest 'STOP) to send
-- Function: stop-process &optional process current-group
This function stops the specified PROCESS. If it is a real
subprocess running a program, it sends the signal ‘SIGTSTP’ to that
subprocess. If PROCESS represents a network, serial, or pipe
connection, this function inhibits handling of the incoming data
from the connection; for a network server, this means not accepting
new connections. Use ‘continue-process’ to resume normal
Outside of Emacs, on systems with job control, the stop character
(usually ‘C-z’) normally sends the ‘SIGTSTP’ signal to a
subprocess. When CURRENT-GROUP is non-‘nil’, you can think of this
function as typing ‘C-z’ on the terminal Emacs uses to communicate
with the subprocess.