[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Starting a subprocess in stopped state

From: Philipp Stephani
Subject: Re: Starting a subprocess in stopped state
Date: Sun, 07 May 2017 12:24:33 +0000

Eli Zaretskii <address@hidden> schrieb am Sa., 6. Mai 2017 um 09:59 Uhr:
> From: Thien-Thi Nguyen <address@hidden>
> Date: Sat, 06 May 2017 07:42:18 +0200
> I see the docstring for ‘make-process’ says:
>  :stop BOOL -- Start process in the ‘stopped’ state if BOOL
>  non-nil.  In the stopped state, a process does not accept
>  incoming data, but you can send outgoing data.  The stopped
>  state is cleared by ‘continue-process’ and set by
>  ‘stop-process’.
> My understanding is that "stopped state", given that "you can
> send outgoing data", is an Emacs-internal data routing concern
> rather than an OS-level concern (SIGTSTP).  The latter would
> completely prevent the asymmetric data feature (documented by
> "you can send outgoing data"), i'd think.

However, stop-process does send SIGTSTP to the process, and
continue-process sends SIGCONT.  The above means that the process
started with :stop non-nil will indeed run, unlike a process which was
stopped with stop-process immediately after starting it.  So there are
two flavors of "stopped" state here, one with SIGTSTP delivered to the
process, the other without.

Also, not reading the Emacs end of the pipe, while the process runs is
probably going to get is to undefined behavior in some situations,
especially with multithreaded processes.

For network or serial or pipe "process", not reading from the
descriptor is all that counts.  But for a local subprocess, this is
not so, IMO.

Is there a way to create a process on Unix and GNU systems, but
prevent it from running until it gets SIGCONT or something similar?

It's at least theoretically possible on macOS using posix_spawn(3) and POSIX_SPAWN_START_SUSPENDED (https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/posix_spawnattr_setflags.3.html). I don't think it's possible using fork/exec (but then, switching to posix_spawn might be a good idea anyway). 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]