From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19115 invoked from network); 8 Jan 2023 04:47:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Jan 2023 04:47:35 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1673153255; b=nZA/7t+vhGk7Q5CnH9pAuyisK7WZ9pQBfChP566Yp6HoYQOqCkm8hBIm8keiLxmUspSdvNIWJj aBB9kFhfjBLd0vwqNNCetzY0F9draulcDKEtrXO7ymo+coaU1v+B0fFkxMWx+2EulhvraEmL9o 50davEYFaZ4xU3HGffDOFcfAYAT1ZC4T7jwlPKBHs5j4QhTXNUCyHdql8K1DPp5Vrhc+u1dUig XDJUi/A4f0v1WOrLJ8Pw/bJD9JWQO0F9uFwpJqfYOOixYC8hVbDvd1uYuT/GS02OOpq0lkKCgP lpwnqNoZASJqWmwrMecih6a6Mz/6eJ7uTAtoXl7QocjLow==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f43.google.com) smtp.remote-ip=209.85.208.43; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1673153255; bh=jiICTAef3i8Au9QKwNk7zii8DZbMfFRzDORGYkvAzoo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=qhn+CxSSDm5HcqxDa3SksNaG1W/GB/AHsJiFwgYRPsqDH7wASx2pM52pUo5rhrzIRGTdIITGrc EkfyJ4ixBv/hGJiFqZ+8aspmEfagrGrNHp9zPSJ391YX/1haCoQ9uPFAYvonWTcra91pl2e2C2 Bkc5C3MI2KA77VRAHYLu3RdBgTdd1aoYHPoQKbhqYkApokn65IyRP65tUyB6w4xbYY8NtqnlHA pUYWuVLTbn3+RN3HLTjHpLYXCGkgihk6q02bRdOeAKCcta8++g0R6wXd6Uk50QWrc/RCc90UqJ WaAsCLGOQ0xlFNB8ZUh2sDq7y16hRTjpryHnECBJCrEB1g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2behoC1ySZ/RQ2qHj2YkLcU7mWblxzLjdBe20Wh+dng=; b=heMnYFhgNss3WuFUbz2hb/PLVf a2GjdvquHdH7wgoTKIIpVyqtz0bNJvnzN0icWBlKt86Kz1FYaTVxYxjCRO4f8FKT6fI3KE9WnNrQO 9z+iqRzdtR1ikhcsEcay0LHRuTbrI4fbooyPe7JRk0D4gaKWqdHtdrIZg0tZ3Rs2L1BDQ4pfgW0jI uOoVjY+HF1QaUgorRQ8vSikJ28EALHBVmkf4cMrVhx2gelOyCSqZxJGyEo3wXfMeiDcQP/iEz/wvQ JyIMtFSk27EnkhYkW2Dnm+3efTnqcC3jzfFklNzEotpPKdolq34ygJW0NF9um796nm2r1kez19Gsx gbbloHgQ==; Received: by zero.zsh.org with local id 1pENap-000B2X-9m; Sun, 08 Jan 2023 04:47:35 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f43.google.com) smtp.remote-ip=209.85.208.43; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f43.google.com ([209.85.208.43]:34313) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pENYA-000AFn-5h; Sun, 08 Jan 2023 04:44:51 +0000 Received: by mail-ed1-f43.google.com with SMTP id z11so7835097ede.1 for ; Sat, 07 Jan 2023 20:44:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2behoC1ySZ/RQ2qHj2YkLcU7mWblxzLjdBe20Wh+dng=; b=PFL0uunBfFl1cGjOpxw2Psga4hNMUnv4DHgjMbxravJt2Oe1+4t1FYfNBUmFAv4kd5 Lo8LD8Axg/2wc55Jyk+MLiYi14rcS7JwUmqqhb3Ds3RhVG2t4OAW8ckLLalAPh8O0NuM oHKOy2dzHfHrxHYpmbQjjNoBH+1yCT9uV8+jvIRt38Wp6HPkI6Tfp8HDaT2yy/E5iNwn NVr8CvZ7nUFVeCp+xYXbFgiMzfmw8lRWx2HuQzDcAIPtgSxjV64pyIDwHPU4ZKo47OXf sWtXOZzGv7kEFEv9FABu7Mwx5q7iOg3fViliO6ezOoIYc8I2LYOQc6TIjKkmvLPtxSA0 ZUvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2behoC1ySZ/RQ2qHj2YkLcU7mWblxzLjdBe20Wh+dng=; b=Spof7HybYB7eM2lnjvkaZXZozUmYNaRnfvNm/h4PUWRef1FsdLdgqR6ZTR7AhrmmT/ 3knewTKCztqsz+02ruhmDMy3PymKHWEbR1T52EkscFkOv9JQ7hDRzoUqOo7cGXcbTKH3 o2w6JIop6GzWXSouOX/Me832s2Vd+H4xXBYGUOqq0J1GLlCoI/YArKYQYTr+Oyh96dwN gDfgdui+zBRN0650mLuEt2OFO7bdif1Fab3kkr02MW2ouCOuxnleJNFgQLOja1k32LvZ yUvyrFfjxAU5p7T9lkUqIu0eym1Ha3mCzAceUs4OR5u1HBLSuUSXaQaQR3ItLtLS5pqG q8gA== X-Gm-Message-State: AFqh2krd409DyyZGxv461LR3hZTehBUvD4OB8b1RW96bLdnIHmcOzpTq dVO8u3gzqn9jhI+z+mHAePhhll63HLkjoxdzDqE= X-Google-Smtp-Source: AMrXdXvpFIA9YEbMed9IVK+kjEJ+85raI/yjnTBPmAV4cydAQ86c5kPA0Eh5h7WtVxEruJX56zcXbEitRLsy9GCenkg= X-Received: by 2002:aa7:cb17:0:b0:48d:eab1:d904 with SMTP id s23-20020aa7cb17000000b0048deab1d904mr2657923edt.47.1673153089326; Sat, 07 Jan 2023 20:44:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pier Paolo Grassi Date: Sun, 8 Jan 2023 05:44:38 +0100 Message-ID: Subject: Re: read with redirected stdin To: linuxtechguy@gmail.com Cc: zsh Content-Type: multipart/alternative; boundary="0000000000008b51d905f1b94f40" X-Seq: 28625 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000008b51d905f1b94f40 Content-Type: text/plain; charset="UTF-8" Thanks, I'll check it out. Il giorno dom 8 gen 2023 alle 05:29 Jim ha scritto: > > On Sat, Jan 7, 2023 at 11:23 AM Pier Paolo Grassi > wrote: > >> Thanks, but i don't _always_ redirect stdin. >> i wonder how is ps getting the tty (it displays an ? when there is no tty >> for the process) >> I suppose it uses /proc, but couldn't find a reference or the info >> exploring the /proc fs by myself. >> for now I am asking directly ps: >> [[ "$(ps h -o tty $$)" != "?" ]] && ... >> >> Pier Paolo Grassi >> >> Hi, > > Don't really have an answer how ps gets its info but the attached script > is something > I have been working on. It uses the /proc file system directly to get > info. It uses zstat > to look for the tty info. If nothing is returned it substitutes '?". > Some processes point to > /dev/null. The script is still a work in progress. I was trying to get the > same results as > "ps -eHo uid=,pid=,ppid=,tty=,comm=" via a zsh script. > > This doesn't answer your original question, but may give you some insight > into the > /proc file system. > > Hope the script is helpful. > > Regards, > > Jim Murphy > > -- Pier Paolo Grassi --0000000000008b51d905f1b94f40 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks, I'll check it out.

Il giorno dom 8 gen 2023 alle 05:29= Jim <linux.tech.guy@gmail.c= om> ha scritto:

On Sat, Jan 7, 2023 at 11:23 AM Pier Paolo Grassi <pierpaolog@gmail.com> = wrote:
Thanks, but i don= 9;t=C2=A0_always_ redirect stdin.
i wonder how is ps getting the = tty (it displays an ? when there is no tty for the process)
I sup= pose it uses /proc, but couldn't find a reference or the info exploring= the /proc fs by myself.
for now I am asking directly ps:
[[ "$(ps h -o tty $$)" !=3D "?" ]] && ...

Pier Paolo Grassi
=

Hi,
=C2=A0
Don't really have an answer how ps gets i= ts info but the attached script is something
I have been working = on. It uses the /proc file system directly to get info. It uses zstat
=
to look for the tty info.=C2=A0 If nothing is returned it substitutes = '?".=C2=A0 Some processes point to
/dev/null. The script= is still a work in progress. I was trying to get the same results as
=
"ps -eHo uid=3D,pid=3D,ppid=3D,tty=3D,comm=3D" via a zsh scr= ipt.

This doesn't answer your original questio= n, but may give you some insight into the
/proc file system.

Hope the script is helpful.

Regards,

Jim Murphy

<= /div>
--
Pier Paolo Grassi
--0000000000008b51d905f1b94f40--