bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 1/2] Fix /proc/*/cmdline.


From: Jeremie Koenig
Subject: [PATCH 1/2] Fix /proc/*/cmdline.
Date: Fri, 13 Aug 2010 06:06:41 +0200

On Linux, the per-process cmdline files should include the whole command line,
with subsequent arguments separated by NUL bytes. However, for some reason we
used to truncate it after the first one and append " \n".

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

diff --git a/procfs_pid_files.c b/procfs_pid_files.c
index 4686153..30194c1 100644
--- a/procfs_pid_files.c
+++ b/procfs_pid_files.c
@@ -429,19 +429,20 @@ 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)
+    goto out;
 
-  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;
 
+out:
   _proc_stat_free (ps); 
-  free (cmdline_data);
   return err;
 }
 
-- 
1.7.1




reply via email to

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