From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Sending EOF to process as part of comint-simple-send Date: Sun, 15 Jan 2023 09:20:21 +0200 Message-ID: <831qnw6z7u.fsf@gnu.org> References: <83v8l971id.fsf@gnu.org> <1c1a3086-1c0a-e4c0-0bd6-6c48cd0efaa3@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29147"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 15 08:20:59 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGxK7-0007Ln-0c for ged-emacs-devel@m.gmane-mx.org; Sun, 15 Jan 2023 08:20:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGxJR-0002TY-MG; Sun, 15 Jan 2023 02:20:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGxJQ-0002TQ-8D for emacs-devel@gnu.org; Sun, 15 Jan 2023 02:20:16 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGxJQ-0003e8-0C; Sun, 15 Jan 2023 02:20:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=mBCoOPO7n/5RBQtAICARU1USvpQ7epN+eDvN032HTD0=; b=NREYAgLqcYbA TuWWilrOjA9pZkJ1kaTlKU7yjPC8YsWGurh354G3Is3uRyUChIGgGuUI83fwF5RUd4srWE4ruLf+4 UHomHryCwy6j3ppFStoS+zYezMCRRI669ncodjemBomDQBuxqKdh+fq5xCQYHFU1x+3td+b9VfqXG mIYvjjCWIQHu7L801v1x5zCZ62QswQm3RpMK0SQe0n0lv1218WJapxlN9fPC8/61XWufZKpZ69s7h D/nFdMr7R001WepRzuDMb7yleOOaIJAstfv6AOw1DXgzyHJbl7/msNQNi/Et40EdCOSonxaIYXjQ4 K0YGpheNDLQtrIzYKqyJzg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGxJP-0005F1-Fp; Sun, 15 Jan 2023 02:20:15 -0500 In-Reply-To: <1c1a3086-1c0a-e4c0-0bd6-6c48cd0efaa3@gmail.com> (message from Jim Porter on Sat, 14 Jan 2023 21:27:56 -0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302425 Archived-At: > Date: Sat, 14 Jan 2023 21:27:56 -0800 > From: Jim Porter > > > So I think comint-simple-send should only send EOF if the > > communications with the process are via a PTY, at least if the > > sub-process is a real process (as opposed to a network or serial or > > pipe process). Or maybe we should only refrain from sending EOF on > > MS-Windows? > > I agree with this: I think we should only call 'process-send-eof' here > when communicating via PTY. (To be precise, whenever the process's > *stdin* is a PTY; as of Emacs 29, a process's stdin can be a PTY even if > its stdout isn't, or vice versa. See commit d7b89ea407.) Yes, I know. The function process-tty-name can be asked to return information about a specific stream. > I imagine you've looked into the relevant POSIX specs already, but just > to explain my reasoning for why I agree... my reading of the POSIX > spec[1] for EOF is that the code above is using it as a way to flush the > I/O buffer for the PTY, which makes sense to me: Right. This doesn't work for pipes, so I intend to introduce a new function that does fsync on the descriptor via which we write to the sub-process, and call it there instead of process-send-eof. Does this make sense?