Date: Tue, 24 Nov 1998 12:14:14 -0500 (EST) From: Alfred Perlstein <bright@hotjobs.com> To: "David E. Cross" <crossd@o2.cs.rpi.edu> Cc: David Wolfskill <dhw@whistle.com>, hackers@FreeBSD.ORG, kpielorz@tdx.co.uk Subject: Re: Getting PID of parent pipe? Message-ID: <Pine.BSF.4.05.9811241211390.10312-100000@bright.fx.genx.net> In-Reply-To: <Pine.SGI.4.05.9811241136390.32239-100000@o2.cs.rpi.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9811241211390.10312-100000>