Author: kib
Date: Wed Jul 11 19:23:11 2018
New Revision: 336204
URL: https://svnweb.freebsd.org/changeset/base/336204

Log:
  MFC r335935:
  Add a way for the process to request cleanup of the kernel cache of
  the process arguments.

Modified:
  stable/11/sys/kern/kern_proc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/kern_proc.c
==============================================================================
--- stable/11/sys/kern/kern_proc.c      Wed Jul 11 18:53:18 2018        
(r336203)
+++ stable/11/sys/kern/kern_proc.c      Wed Jul 11 19:23:11 2018        
(r336204)
@@ -1945,11 +1945,20 @@ sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS)
 
        if (req->newlen > ps_arg_cache_limit - sizeof(struct pargs))
                return (ENOMEM);
-       newpa = pargs_alloc(req->newlen);
-       error = SYSCTL_IN(req, newpa->ar_args, req->newlen);
-       if (error != 0) {
-               pargs_free(newpa);
-               return (error);
+
+       if (req->newlen == 0) {
+               /*
+                * Clear the argument pointer, so that we'll fetch arguments
+                * with proc_getargv() until further notice.
+                */
+               newpa = NULL;
+       } else {
+               newpa = pargs_alloc(req->newlen);
+               error = SYSCTL_IN(req, newpa->ar_args, req->newlen);
+               if (error != 0) {
+                       pargs_free(newpa);
+                       return (error);
+               }
        }
        PROC_LOCK(p);
        pa = p->p_args;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to