Print this page
XXXX adding PID information to netstat output

@@ -176,10 +176,17 @@
                 } else {
                         if (cmd == F_DUPFD_CLOEXEC) {
                                 f_setfd(retval, FD_CLOEXEC);
                         }
                 }
+
+                if (error == 0 && fp->f_vnode != NULL) {
+                        (void) VOP_IOCTL(fp->f_vnode, F_FORKED,
+                                (intptr_t) p, FKIOCTL,
+                                kcred, NULL, NULL);
+                }
+
                 goto done;
 
         case F_DUP2FD_CLOEXEC:
                 if (fdes == iarg) {
                         error = EINVAL;

@@ -212,20 +219,35 @@
                          */
                         mutex_enter(&fp->f_tlock);
                         fp->f_count++;
                         mutex_exit(&fp->f_tlock);
                         releasef(fdes);
+
+                        /* assume we have forked successfully */
+
+                        if (fp->f_vnode != NULL) {
+                                (void) VOP_IOCTL(fp->f_vnode, F_FORKED,
+                                        (intptr_t) p, FKIOCTL,
+                                        kcred, NULL, NULL);
+                        }
+
                         if ((error = closeandsetf(iarg, fp)) == 0) {
                                 if (cmd == F_DUP2FD_CLOEXEC) {
                                         f_setfd(iarg, FD_CLOEXEC);
                                 }
                                 retval = iarg;
                         } else {
                                 mutex_enter(&fp->f_tlock);
                                 if (fp->f_count > 1) {
                                         fp->f_count--;
                                         mutex_exit(&fp->f_tlock);
+                                        if (fp->f_vnode != NULL) {
+                                                VOP_IOCTL(fp->f_vnode, F_CLOSED,
+                                                        (intptr_t) p, FKIOCTL,
+                                                        kcred, NULL, NULL);
+                                        }
+
                                 } else {
                                         mutex_exit(&fp->f_tlock);
                                         (void) closef(fp);
                                 }
                         }