From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.devel Subject: Re: Forwarding stdout/stderr of a child process in batch mode Date: Sun, 6 Dec 2020 22:40:39 +0100 Message-ID: References: <86eek3qcod.fsf@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31882"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs developers To: Zhu Zihao Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 06 22:41:55 2020 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 1km1n0-0008DI-Ty for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Dec 2020 22:41:54 +0100 Original-Received: from localhost ([::1]:49204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1km1mz-0003Bz-W1 for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Dec 2020 16:41:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1km1m1-0002HS-41 for emacs-devel@gnu.org; Sun, 06 Dec 2020 16:40:53 -0500 Original-Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]:41827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1km1lz-0003du-HI for emacs-devel@gnu.org; Sun, 06 Dec 2020 16:40:52 -0500 Original-Received: by mail-oi1-x22f.google.com with SMTP id 15so2072918oix.8 for ; Sun, 06 Dec 2020 13:40:51 -0800 (PST) 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=Ktl4QGZi1XJ2d5lryE0IkOZXnWV9UZvmaOZr8UIAYgI=; b=B4I8h/q5pHHnmnC4Qp1xzvEl7pMPCs9uxs18RIIdrvZtEDmgtzSMu7sJvl0RasR+lw 81OdBRdjsI3uizUP+zX8NX4On941EarB3JpGdiBtI14KxrfI9woW1yIx09YvLFc4Df05 o+7CdvSaZw+gO5NBmtwQvyGDOqFItoT4jePNkP7GHX3RueXseCa+Mz2uKOQhiGCbDlYq D8k+sptrokLcUlMwIyYD7XE4TkNjVQqT1zO1KnHIqcoSdWEHeLkJ49kCrd+TIGd/edV+ +vbn8cQ1LlGGFTTHe1MiIqdVbGZw/pXuBfBEiYAI8pgRWH4VCfg7rD/dJlMG5eeW708m RMVg== 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=Ktl4QGZi1XJ2d5lryE0IkOZXnWV9UZvmaOZr8UIAYgI=; b=qOkPwXYo4Cwmy+RyQikDy24093OeElHLsZcfVVzcBjOlSI506QKYkw47i/qmEqymHX 7n+pisDhB0uEjGGEfae04HpTdfGDJi3B7ReDFbCptsrmdRxhwLDyA0V+L7arV+PCr+8h uybnk6RFG7Zso1FeE84yBpu2X1ahLADhTbBPudwufbpvS/zjvT4ThZRp/zDK2OAGuK7K ORFV/hJXd9TRF2E0NHPNBlDkrBk9InBEdBGSgn3F7vRS2179VoyTTBdiOZNJ3fHG1zmp PtdHSvxreihST/RqlU3JkOwnt4r2lZjD/TVChY1mzgQOn1GSb8ypqQP/zu6SXEVvBmbR /iRQ== X-Gm-Message-State: AOAM530Xx64RlAxQlPeGtYcemskmxJtEgYhu7I0kxFOJkpGUyOwR4nqu 4ZnSUsE2X7QwvrMQdjBnsC8U1/j2ODsaiqXGuA== X-Google-Smtp-Source: ABdhPJwy/NBd0onWIJ3tKW5PnhByiK5ANy/DRpTWwyYBq2ApABpPbCuVaMZcFgpiXNpTvW88ziRMyt97dnwk9GKI/Jc= X-Received: by 2002:a05:6808:563:: with SMTP id j3mr10662189oig.48.1607290850423; Sun, 06 Dec 2020 13:40:50 -0800 (PST) In-Reply-To: <86eek3qcod.fsf@163.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=pogonyshev@gmail.com; helo=mail-oi1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:260463 Archived-At: Thank you, this seems to work (haven't tried separating stderr from stdout yet). Is there a normal way to wait for asynchronous process to terminate? Currently I have managed to make it work by throwing from sentinel, but this feels a bit hackish, maybe there is something better? Currently I have something like this: (let ((process (make-process ... :sentinel (lambda (_process _event) (throw 'done nil))))) (catch 'done (while (process-live-p process) (accept-process-output nil 60))) ... Paul On Sun, 6 Dec 2020 at 14:37, Zhu Zihao wrote: > > > IMO, in batch mode, `message` writes to stderr, `princ` writes to > stdout. You can install a filter for childprocess, and run functions I > mentioned above to forward these outputs. > > > Paul Pogonyshev writes: > > > Hi, > > > > I'm using Emacs in batch mode. I need to invoke a child process that > > is a longish operation (a few minutes). During this time, it writes to > > its stdout, so user will see that it is working and what exactly is > > being done. However, if I invoke it from Emacs (e.g. using > > `call-process') I see no way of forwarding this output to the "real" > > stdout. So, for a user this looks like the process (or batch Emacs on > > top of it) is hung. > > > > Am I missing a way to forward output? > > > > Paul > > > -- > Retrieve my PGP public key: https://meta.sr.ht/~citreu.pgp > > Zihao