On Sat, Jul 30, 2016 at 8:33 PM, Grazvydas Ignotas <nota...@gmail.com> wrote:
> On Sat, Jul 30, 2016 at 6:22 PM, Marek Olšák <mar...@gmail.com> wrote:
>> From: Marek Olšák <marek.ol...@amd.com>
>>
>> for debugging
>> ---
>>  src/gallium/auxiliary/os/os_process.c | 37 
>> +++++++++++++++++++++++++++++++++++
>>  src/gallium/auxiliary/os/os_process.h |  2 ++
>>  2 files changed, 39 insertions(+)
>>
>> diff --git a/src/gallium/auxiliary/os/os_process.c 
>> b/src/gallium/auxiliary/os/os_process.c
>> index 332e195..3ee30b1 100644
>> --- a/src/gallium/auxiliary/os/os_process.c
>> +++ b/src/gallium/auxiliary/os/os_process.c
>> @@ -30,6 +30,10 @@
>>  #include "os/os_process.h"
>>  #include "util/u_memory.h"
>>
>> +#if defined(PIPE_OS_UNIX)
>> +#include <stdio.h>
>> +#endif
>> +
>>  #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
>>  #  include <windows.h>
>>  #elif defined(__GLIBC__) || defined(__CYGWIN__)
>> @@ -108,3 +112,36 @@ os_get_process_name(char *procname, size_t size)
>>        return FALSE;
>>     }
>>  }
>> +
>> +bool
>> +os_get_process_cmd_line(char *result, size_t size)
>> +{
>> +#if defined(PIPE_OS_UNIX)
>> +   char ps[256];
>> +   int len;
>> +   FILE *p;
>> +
>> +   /* Execute the ps command. */
>> +   snprintf(ps, sizeof(ps), "ps --pid %i -o args --no-headers", getpid());
>> +
>> +   p = popen(ps, "r");
>
> What about just reading /proc/self/cmdline ? To exec ps, the current
> process will have to fork which will fail if there is not enough free
> RAM for the forked copy, which is not that unlikely with games as they
> tend to be resource heavy.

Are you sure it makes a copy of the current process? The affected code
already uses popen to read dmesg. This series only adds a second popen
call.

Marek
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to