* Starting a subprocess in stopped state @ 2017-05-02 19:04 Eli Zaretskii 2017-05-05 7:29 ` Eli Zaretskii 0 siblings, 1 reply; 11+ messages in thread From: Eli Zaretskii @ 2017-05-02 19:04 UTC (permalink / raw) To: emacs-devel My reading of process.c seems to indicate that the :stop attribute of make-process only has effect on network or serial or pipe process types; a process running a program cannot use that attribute, and can only stopped by explicitly calling stop-process. Is this correct, or did I miss something? This is not explicitly documented. What I see in the code is that when make-process is called with the :stop attribute non-nil, the file descriptor to be used for reading the process output is not added to the list of descriptors watched by pselect. But that doesn't really suspend the process like SIGTSTP would, right? And I see no other code that specifically handles the :stop attribute. Am I missing something? TIA ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-02 19:04 Starting a subprocess in stopped state Eli Zaretskii @ 2017-05-05 7:29 ` Eli Zaretskii 2017-05-06 5:42 ` Thien-Thi Nguyen 0 siblings, 1 reply; 11+ messages in thread From: Eli Zaretskii @ 2017-05-05 7:29 UTC (permalink / raw) To: Daiki Ueno; +Cc: emacs-devel > Date: Tue, 02 May 2017 22:04:27 +0300 > From: Eli Zaretskii <eliz@gnu.org> > > My reading of process.c seems to indicate that the :stop attribute of > make-process only has effect on network or serial or pipe process > types; a process running a program cannot use that attribute, and can > only be stopped by explicitly calling stop-process. Is this correct, > or did I miss something? This is not explicitly documented. > > What I see in the code is that when make-process is called with the > :stop attribute non-nil, the file descriptor to be used for reading > the process output is not added to the list of descriptors watched by > pselect. But that doesn't really suspend the process like SIGTSTP > would, right? And I see no other code that specifically handles the > :stop attribute. Am I missing something? Ping! Can someone please confirm or refute my observations above? Daiki? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-05 7:29 ` Eli Zaretskii @ 2017-05-06 5:42 ` Thien-Thi Nguyen 2017-05-06 7:58 ` Eli Zaretskii 0 siblings, 1 reply; 11+ messages in thread From: Thien-Thi Nguyen @ 2017-05-06 5:42 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 1613 bytes --] () Eli Zaretskii <eliz@gnu.org> () Fri, 05 May 2017 10:29:52 +0300 > What I see in the code is that when make-process is called > with the :stop attribute non-nil, the file descriptor to be > used for reading the process output is not added to the > list of descriptors watched by pselect. But that doesn't > really suspend the process like SIGTSTP would, right? And > I see no other code that specifically handles the :stop > attribute. Am I missing something? confirm or refute 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. So, omission from ‘pselect’ fd list is a correct implementation. If anyone can refute this refutation, please do -- i'm all ears (in a "stopped state", myself :-D)! -- Thien-Thi Nguyen ----------------------------------------------- (defun responsep (query) (pcase (context query) (`(technical ,ml) (correctp ml)) ...)) 748E A0E8 1CB8 A748 9BFA --------------------------------------- 6CE4 6703 2224 4C80 7502 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-06 5:42 ` Thien-Thi Nguyen @ 2017-05-06 7:58 ` Eli Zaretskii 2017-05-07 12:24 ` Philipp Stephani ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Eli Zaretskii @ 2017-05-06 7:58 UTC (permalink / raw) To: emacs-devel; +Cc: Daiki Ueno > From: Thien-Thi Nguyen <ttn@gnu.org> > 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? (There is such a way on MS-Windows.) Debuggers do that, of course, but I don't mean starting a process as a debugger would, since that would be gross, and probably requires special privileges at least on some systems. Thanks. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-06 7:58 ` Eli Zaretskii @ 2017-05-07 12:24 ` Philipp Stephani 2017-05-07 17:16 ` Eli Zaretskii 2017-05-07 17:25 ` Paul Eggert 2017-05-08 16:41 ` Davis Herring 2 siblings, 1 reply; 11+ messages in thread From: Philipp Stephani @ 2017-05-07 12:24 UTC (permalink / raw) To: Eli Zaretskii, emacs-devel; +Cc: Daiki Ueno [-- Attachment #1: Type: text/plain, Size: 2045 bytes --] Eli Zaretskii <eliz@gnu.org> schrieb am Sa., 6. Mai 2017 um 09:59 Uhr: > > From: Thien-Thi Nguyen <ttn@gnu.org> > > 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). [-- Attachment #2: Type: text/html, Size: 2681 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-07 12:24 ` Philipp Stephani @ 2017-05-07 17:16 ` Eli Zaretskii 0 siblings, 0 replies; 11+ messages in thread From: Eli Zaretskii @ 2017-05-07 17:16 UTC (permalink / raw) To: Philipp Stephani; +Cc: ueno, emacs-devel > From: Philipp Stephani <p.stephani2@gmail.com> > Date: Sun, 07 May 2017 12:24:33 +0000 > Cc: Daiki Ueno <ueno@gnu.org> > > 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). Thanks. However, since this an Apple extension, I don't think we can use it unless there's an equivalent feature on other Unix and GNU systems. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-06 7:58 ` Eli Zaretskii 2017-05-07 12:24 ` Philipp Stephani @ 2017-05-07 17:25 ` Paul Eggert 2017-05-07 17:57 ` Eli Zaretskii 2017-05-07 18:05 ` Andreas Schwab 2017-05-08 16:41 ` Davis Herring 2 siblings, 2 replies; 11+ messages in thread From: Paul Eggert @ 2017-05-07 17:25 UTC (permalink / raw) To: Eli Zaretskii, emacs-devel; +Cc: Daiki Ueno Eli Zaretskii wrote: > 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? Sure, the parent can fork and the child can send itself a SIGSTOP before doing the exec. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-07 17:25 ` Paul Eggert @ 2017-05-07 17:57 ` Eli Zaretskii 2017-05-07 18:05 ` Andreas Schwab 1 sibling, 0 replies; 11+ messages in thread From: Eli Zaretskii @ 2017-05-07 17:57 UTC (permalink / raw) To: Paul Eggert; +Cc: ueno, emacs-devel > Cc: Daiki Ueno <ueno@gnu.org> > From: Paul Eggert <eggert@cs.ucla.edu> > Date: Sun, 7 May 2017 10:25:03 -0700 > > Eli Zaretskii wrote: > > 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? > > Sure, the parent can fork and the child can send itself a SIGSTOP before doing > the exec. Thanks. I think we should do this when make-process was called with ':stop' non-nil. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-07 17:25 ` Paul Eggert 2017-05-07 17:57 ` Eli Zaretskii @ 2017-05-07 18:05 ` Andreas Schwab 1 sibling, 0 replies; 11+ messages in thread From: Andreas Schwab @ 2017-05-07 18:05 UTC (permalink / raw) To: Paul Eggert; +Cc: Eli Zaretskii, Daiki Ueno, emacs-devel On Mai 07 2017, Paul Eggert <eggert@cs.ucla.edu> wrote: > Eli Zaretskii wrote: >> 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? > > Sure, the parent can fork and the child can send itself a SIGSTOP before > doing the exec. That will also delay all error reporting, though. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-06 7:58 ` Eli Zaretskii 2017-05-07 12:24 ` Philipp Stephani 2017-05-07 17:25 ` Paul Eggert @ 2017-05-08 16:41 ` Davis Herring 2017-05-08 16:46 ` Eli Zaretskii 2 siblings, 1 reply; 11+ messages in thread From: Davis Herring @ 2017-05-08 16:41 UTC (permalink / raw) To: Eli Zaretskii, emacs-devel; +Cc: Daiki Ueno > 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. I don't think it's undefined behavior -- you may just hang (one or more threads of) the subprocess. Of course, then it is stopped, much as if by SIGSTOP. Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Starting a subprocess in stopped state 2017-05-08 16:41 ` Davis Herring @ 2017-05-08 16:46 ` Eli Zaretskii 0 siblings, 0 replies; 11+ messages in thread From: Eli Zaretskii @ 2017-05-08 16:46 UTC (permalink / raw) To: Davis Herring; +Cc: ueno, emacs-devel > From: Davis Herring <herring@lanl.gov> > Date: Mon, 8 May 2017 10:41:28 -0600 > Cc: Daiki Ueno <ueno@gnu.org> > > > 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. > > I don't think it's undefined behavior -- you may just hang (one or more > threads of) the subprocess. Well, that's what I meant by "undefined" -- the exact result depends on factors beyond our control, some of them depend on the program being run, some on the OS and its configuration (like the size of the pipe buffer). ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-05-08 16:46 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-02 19:04 Starting a subprocess in stopped state Eli Zaretskii 2017-05-05 7:29 ` Eli Zaretskii 2017-05-06 5:42 ` Thien-Thi Nguyen 2017-05-06 7:58 ` Eli Zaretskii 2017-05-07 12:24 ` Philipp Stephani 2017-05-07 17:16 ` Eli Zaretskii 2017-05-07 17:25 ` Paul Eggert 2017-05-07 17:57 ` Eli Zaretskii 2017-05-07 18:05 ` Andreas Schwab 2017-05-08 16:41 ` Davis Herring 2017-05-08 16:46 ` Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.