From owner-freebsd-hackers Tue Nov 24 08:39:19 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA09205 for freebsd-hackers-outgoing; Tue, 24 Nov 1998 08:39:19 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from o2.cs.rpi.edu (o2.cs.rpi.edu [128.113.96.156]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA09197 for ; Tue, 24 Nov 1998 08:39:17 -0800 (PST) (envelope-from crossd@o2.cs.rpi.edu) Received: from localhost (crossd@localhost) by o2.cs.rpi.edu (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id LAA33678; Tue, 24 Nov 1998 11:39:06 -0500 (EST) Date: Tue, 24 Nov 1998 11:38:58 -0500 From: "David E. Cross" To: David Wolfskill cc: hackers@FreeBSD.ORG, kpielorz@tdx.co.uk Subject: Re: Getting PID of parent pipe? In-Reply-To: <199811241614.IAA08037@pau-amma.whistle.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 24 Nov 1998, David Wolfskill wrote: > >Date: Fri, 20 Nov 1998 11:48:49 +0000 > >From: Karl Pielorz > > >Is there an 'easy' way of getting the PID of a parent process feeding a > >command's stdin? > > >e.g. > > >cat something | foo | bar > > >I need to get the PID of foo while running as bar... > > If "bar" is something you can control/modify, it would seem that > getppid() would be an appropriate tool. that would return to him the PID of the shell process, not the PID of 'foo' (the process which is feeding the pipe). I don't know of an easy way from 'bar' to get the PID of 'foo'. You could do it with a method similar too lsof, but that would require special privs that you may or may not have, and a good deal of effort. -- David Cross To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message