From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Starting a subprocess in stopped state Date: Sun, 07 May 2017 12:24:33 +0000 Message-ID: References: <831ss7hyh0.fsf@gnu.org> <83tw4zg3rj.fsf@gnu.org> <87bmr6wngl.fsf@zigzag> <83bmr6fmch.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11442bc61fb035054eee35a6 X-Trace: blaine.gmane.org 1494159902 12225 195.159.176.226 (7 May 2017 12:25:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 7 May 2017 12:25:02 +0000 (UTC) Cc: Daiki Ueno To: Eli Zaretskii , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 07 14:24:52 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7LF6-0002yY-8U for ged-emacs-devel@m.gmane.org; Sun, 07 May 2017 14:24:52 +0200 Original-Received: from localhost ([::1]:54925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7LFB-0003vk-8V for ged-emacs-devel@m.gmane.org; Sun, 07 May 2017 08:24:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7LF2-0003uV-LU for emacs-devel@gnu.org; Sun, 07 May 2017 08:24:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7LF1-0000dD-Ha for emacs-devel@gnu.org; Sun, 07 May 2017 08:24:48 -0400 Original-Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:37832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d7LEz-0000bl-At; Sun, 07 May 2017 08:24:45 -0400 Original-Received: by mail-wm0-x22c.google.com with SMTP id m123so38987877wma.0; Sun, 07 May 2017 05:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CRXcuQIPBwlzogrW/4kbiXCva3WdtwnrX9YX+l4YtxU=; b=unHg+hPMuspoomJQRINCK1RdTif0SyIud30AF7qyCltw+NwummZw+u4WOit2eq4ZdV T/afhNUu9BWRVLSZW31oRGdupj+QLrjulKfZ7Qho6XW1ds56DqMGWL4z5g5JiT3cMPNA kQ+fgmPTEV7EWhLrQlQMU2jiNd6r4LQUvrZEUIP7AjRMPl8WuLb9MII7y7Z1wh/fJOEm 3G9L92AxTHb5QnASoOO5h7roLG+uHoBhw73/aLeWPSInlYk+e+1KNrUS/4sIhV5F/A/6 O4vJYGa8H425PyU28rWoI79ocNnbD6PReX2CWRAvbJTje/u/PNSHWJp2tH+3viYFlJw3 pPvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CRXcuQIPBwlzogrW/4kbiXCva3WdtwnrX9YX+l4YtxU=; b=NKu4DOvUQsVm87ZyUn6NUufViEbesc25w4qEiOTi3KnKBXBMNvhP2ZqKbUUtbTa//Z NDQEcAl+nsxZ4CS6zAB9+HioCVaFbx2kJfp/OmmoY+WmAeG/9G0Xj8FJMfqm3C9O6Smk 1F666Ffu1jRvH8fnSNLzAq3Y7NeW4/pqoJRMMr5OErnlHvHVGRl7KNjS8DU/+rDeQ/IN i0FIXCBWQx69F3QKdwm7if3hacul5xRksBJWtt3aRg7vWd44lYCPOtHM9AH5nAKVyzlk APWOQMmqH1bPZbFp23O3fLRQj5D7l3H2EqO0+7rD4qmeh4sVhr6OJCjlWyvrUk7fOUCF oz3A== X-Gm-Message-State: AODbwcBRfwCg3qE3F5eB48OXf0oWFf91Mk9Stci6EYJAbJZOW0GYUOOj HCUKrzcPlpPKY/3VciSOUnrv54mANKBd X-Received: by 10.28.14.17 with SMTP id 17mr1864030wmo.95.1494159884003; Sun, 07 May 2017 05:24:44 -0700 (PDT) In-Reply-To: <83bmr6fmch.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214664 Archived-At: --001a11442bc61fb035054eee35a6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii schrieb am Sa., 6. Mai 2017 um 09:59 Uhr: > > From: Thien-Thi Nguyen > > Date: Sat, 06 May 2017 07:42:18 +0200 > > > > I see the docstring for =E2=80=98make-process=E2=80=99 says: > > > > :stop BOOL -- Start process in the =E2=80=98stopped=E2=80=99 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 =E2=80=98continue-process=E2=80=99 and set by > > =E2=80=98stop-process=E2=80=99. > > > > 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/M= anPages/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). --001a11442bc61fb035054eee35a6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Sa., 6. Mai 2017 um 09:59=C2=A0Uhr:
ttn@gnu.org>
> Date: Sat, 06 May 2017 07:42:18 +0200
>
> I see the docstring for =E2=80=98make-process=E2=80=99 says:
>
>=C2=A0 :stop BOOL -- Start process in the =E2=80=98stopped=E2=80=99 sta= te if BOOL
>=C2=A0 non-nil.=C2=A0 In the stopped state, a process does not accept >=C2=A0 incoming data, but you can send outgoing data.=C2=A0 The stopped=
>=C2=A0 state is cleared by =E2=80=98continue-process=E2=80=99 and set b= y
>=C2=A0 =E2=80=98stop-process=E2=80=99.
>
> My understanding is that "stopped state", given that "y= ou can
> send outgoing data", is an Emacs-internal data routing concern > rather than an OS-level concern (SIGTSTP).=C2=A0 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.=C2=A0 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.=C2=A0 So there are=
two flavors of "stopped" state here, one with SIGTSTP delivered t= o 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.=C2=A0 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/libr= ary/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).=C2=A0
--001a11442bc61fb035054eee35a6--