aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-12-28 23:31:50 +0100
committerMarc Haesen <marc@hc-consult.be>2011-12-28 23:31:50 +0100
commit9715b7fab0757c86e1bb151f3dce0b324bcff692 (patch)
tree805e01d9e21e3f5316e8827dd59173a7a5cfd4ae /xorg-server/os
parent0fd2d56b0fc0ce74c5f3e5e23cb26b0d1a075ba1 (diff)
downloadvcxsrv-9715b7fab0757c86e1bb151f3dce0b324bcff692.tar.gz
vcxsrv-9715b7fab0757c86e1bb151f3dce0b324bcff692.tar.bz2
vcxsrv-9715b7fab0757c86e1bb151f3dce0b324bcff692.zip
xserver libX11 mesa xkeyboard-config git update 28 dec 2011
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/client.c69
1 files changed, 59 insertions, 10 deletions
diff --git a/xorg-server/os/client.c b/xorg-server/os/client.c
index 4aec097e1..8f4707b09 100644
--- a/xorg-server/os/client.c
+++ b/xorg-server/os/client.c
@@ -59,6 +59,11 @@
#include "os.h"
#include "dixstruct.h"
+#ifdef __sun
+#include <errno.h>
+#include <procfs.h>
+#endif
+
/**
* Try to determine a PID for a client from its connection
* information. This should be called only once when new client has
@@ -117,8 +122,6 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
{
char path[PATH_MAX + 1];
int totsize = 0;
- int cmdsize = 0;
- int argsize = 0;
int fd = 0;
if (cmdname)
@@ -129,6 +132,48 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
if (pid == -1)
return;
+#ifdef __sun /* Solaris */
+ /* Solaris does not support /proc/pid/cmdline, but makes information
+ * similar to what ps shows available in a binary structure in the
+ * /proc/pid/psinfo file. */
+ if (snprintf(path, sizeof(path), "/proc/%d/psinfo", pid) < 0)
+ return;
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ {
+ ErrorF ("Failed to open %s: %s\n", path, strerror(errno));
+ return;
+ }
+ else
+ {
+ psinfo_t psinfo = { 0 };
+ char *sp;
+
+ totsize = read(fd, &psinfo, sizeof(psinfo_t));
+ close(fd);
+ if (totsize <= 0)
+ return;
+
+ /* pr_psargs is the first PRARGSZ (80) characters of the command
+ * line string - assume up to the first space is the command name,
+ * since it's not delimited. While there is also pr_fname, that's
+ * more limited, giving only the first 16 chars of the basename of
+ * the file that was exec'ed, thus cutting off many long gnome
+ * command names, or returning "isapython2.6" for all python scripts.
+ */
+ psinfo.pr_psargs[PRARGSZ-1] = '\0';
+ sp = strchr(psinfo.pr_psargs, ' ');
+ if (sp)
+ *sp++ = '\0';
+
+ if (cmdname)
+ *cmdname = strdup(psinfo.pr_psargs);
+
+ if (cmdargs && sp)
+ *cmdargs = strdup(sp);
+ }
+#else /* not Solaris */
+
/* Check if /proc/pid/cmdline exists. It's not supported on all
* operating systems. */
if (snprintf(path, sizeof(path), "/proc/%d/cmdline", pid) < 0)
@@ -146,17 +191,20 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
path[totsize - 1] = '\0';
/* Contruct the process name without arguments. */
- cmdsize = strlen(path) + 1;
if (cmdname)
{
*cmdname = strdup(path);
}
/* Construct the arguments for client process. */
- argsize = totsize - cmdsize;
- if (cmdargs && (argsize > 0))
+ if (cmdargs)
{
- char *args = malloc(argsize);
+ int cmdsize = strlen(path) + 1;
+ int argsize = totsize - cmdsize;
+ char *args = NULL;
+
+ if (argsize > 0)
+ args = malloc(argsize);
if (args)
{
int i = 0;
@@ -169,6 +217,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
*cmdargs = args;
}
}
+#endif
}
/**
@@ -192,9 +241,9 @@ void ReserveClientIds(struct _Client *client)
DetermineClientCmd(client->clientIds->pid, &client->clientIds->cmdname, &client->clientIds->cmdargs);
DebugF("client(%lx): Reserved pid(%d).\n",
- client->clientAsMask, client->clientIds->pid);
+ (unsigned long) client->clientAsMask, client->clientIds->pid);
DebugF("client(%lx): Reserved cmdname(%s) and cmdargs(%s).\n",
- client->clientAsMask,
+ (unsigned long) client->clientAsMask,
client->clientIds->cmdname ? client->clientIds->cmdname : "NULL",
client->clientIds->cmdargs ? client->clientIds->cmdargs : "NULL");
#endif /* CLIENTIDS */
@@ -216,9 +265,9 @@ void ReleaseClientIds(struct _Client *client)
return;
DebugF("client(%lx): Released pid(%d).\n",
- client->clientAsMask, client->clientIds->pid);
+ (unsigned long) client->clientAsMask, client->clientIds->pid);
DebugF("client(%lx): Released cmdline(%s) and cmdargs(%s).\n",
- client->clientAsMask,
+ (unsigned long) client->clientAsMask,
client->clientIds->cmdname ? client->clientIds->cmdname : "NULL",
client->clientIds->cmdargs ? client->clientIds->cmdargs : "NULL");