From owner-freebsd-hackers Tue Nov 24 09:10:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA13500 for freebsd-hackers-outgoing; Tue, 24 Nov 1998 09:10:34 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from bright.fx.genx.net (bright.fx.genx.net [206.64.4.154]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA13495 for ; Tue, 24 Nov 1998 09:10:31 -0800 (PST) (envelope-from bright@hotjobs.com) Received: from localhost (bright@localhost) by bright.fx.genx.net (8.9.1/8.9.1) with ESMTP id MAA15679; Tue, 24 Nov 1998 12:14:14 -0500 (EST) (envelope-from bright@hotjobs.com) X-Authentication-Warning: bright.fx.genx.net: bright owned process doing -bs Date: Tue, 24 Nov 1998 12:14:14 -0500 (EST) From: Alfred Perlstein X-Sender: bright@bright.fx.genx.net To: "David E. Cross" cc: David Wolfskill , hackers@FreeBSD.ORG, kpielorz@tdx.co.uk Subject: Re: Getting PID of parent pipe? In-Reply-To: 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 E. Cross wrote: > > >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. > This would be very hard to do considering that pipes are full duplex and the fact that many processes can have a pipe open. In fact getting the uid associated with a socket/pipe is difficult as well. Consider fd passing as another problem but perhaps a solution. -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message