On Fri, Dec 04, 2009 at 08:57:18AM +0100, Claudio Jeker wrote: > On Thu, Dec 03, 2009 at 11:50:52PM -0800, patrick keshishian wrote: > > On Fri, Dec 04, 2009 at 09:34:31AM +0200, Vladimir Kirillov wrote: > > > Hello t...@! > > > > > > Here's a diff for tun to make it keep record and display the > > > pid of tunnel owner process in ifconfig. > > > I'm sure it would be a handy feature, hope you'll like it. > > [dd] > > > @@ -561,6 +566,15 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, > > > case SIOCGIFMEDIA: > > > case SIOCSIFMEDIA: > > > error = ifmedia_ioctl(ifp, ifr, &tp->tun_media, cmd); > > > + break; > > > + > > > + case SIOCGTUNPID: > > > + if (tp->tun_proc == NULL) { > > > + error = ENOTTY; > > > + break; > > > + } > > > + > > > + tunr->tun_pid = tp->tun_proc->p_pid; > > > break; > > > > > > Just a personal comment, why not: > > > > + case SIOCGTUNPID: > > + if (tp->tun_proc == NULL) > > + error = ENOTTY; > > + else > > + tunr->tun_pid = tp->tun_proc->p_pid; > > break; > > > > Just so it is more consistent with the rest of the code? > > > > The main problem with this code is that ENOTTY is the wrong errno to > return. ENOTTY has a very specific meaning.
It's hard to pick the right one. ESRCH seems close, but is for the reverse situation (you're requesting info for a pid taht does not exist). How about ECHILD? > > -- > :wq Claudio