bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/5] Fix /proc/*/cmdline


From: Jeremie Koenig
Subject: [PATCH 1/5] Fix /proc/*/cmdline
Date: Mon, 16 Aug 2010 13:36:48 +0200

On Linux, /proc/NNNN/cmdline is a NUL-separated list of arguments.
We used to truncate after the first one and add some whitespace.

Signed-off-by: Jeremie Koenig <address@hidden>
---
 procfs_pid_files.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/procfs_pid_files.c b/procfs_pid_files.c
index 4686153..9dbe3eb 100644
--- a/procfs_pid_files.c
+++ b/procfs_pid_files.c
@@ -429,19 +429,19 @@ procfs_read_cmdline_file (struct procfs_dir_entry 
*dir_entry,
   error_t err;
   struct proc_stat *ps;
   pid_t pid = atoi (dir_entry->dir->node->nn->dir_entry->name);
+
   err = _proc_stat_create (pid, ps_context, &ps);
+  if (err)
+    return err;
 
   err = set_field_value (ps, PSTAT_ARGS);
-
   if (! err)
-    if (asprintf (&cmdline_data, "%s \n", ps->args) == -1)
-      return errno;
-
-  memcpy (data, cmdline_data, strlen(cmdline_data));
-  *len = strlen (data);
+    {
+      memcpy (data, ps->args, ps->args_len);
+      *len = ps->args_len;
+    }
 
   _proc_stat_free (ps); 
-  free (cmdline_data);
   return err;
 }
 
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]