diff options
author | George Lebl <jirka@5z.com> | 2003-07-07 22:44:35 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2003-07-07 22:44:35 +0000 |
commit | c4db5728a4673f7c86024c3ffef4f106f420786e (patch) | |
tree | 97885c77e04a5e7026d6429e6d2ca22f6ef14fe9 /gui | |
parent | 6a7c751bada7782d0567d13e98259dfc3b5d2389 (diff) | |
download | gdm-c4db5728a4673f7c86024c3ffef4f106f420786e.tar.gz |
the display check code was wrong, it only used the tcp connections. Which
Mon Jul 07 15:42:44 2003 George Lebl <jirka@5z.com>
* daemon/misc.c, gui/gdmXnestchooser.c: the display check code was
wrong, it only used the tcp connections. Which are the most robust
way, but we also really need to check the lock file.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/gdmXnestchooser.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gui/gdmXnestchooser.c b/gui/gdmXnestchooser.c index 6cd72558..c6ade39a 100644 --- a/gui/gdmXnestchooser.c +++ b/gui/gdmXnestchooser.c @@ -64,6 +64,7 @@ get_free_display (void) for (i = 20; i < 3000; i ++) { struct stat s; char buf[256]; + FILE *fp; sock = socket (AF_INET, SOCK_STREAM, 0); serv_addr.sin_port = htons (6000 + i); @@ -78,6 +79,23 @@ get_free_display (void) close (sock); + /* if lock file exists and the process exists */ + g_snprintf (buf, sizeof (buf), "/tmp/.X%d-lock", i); + fp = fopen (buf, "r"); + if (fp != NULL) { + char buf2[100]; + if (fgets (buf2, sizeof (buf2), fp) != NULL) { + gulong pid; + if (sscanf (buf2, "%lu", &pid) == 1 && + kill (pid, 0) == 0) { + fclose (fp); + continue; + } + + } + fclose (fp); + } + g_snprintf (buf, sizeof (buf), "/tmp/.X11-unix/X%d", i); if (stat (buf, &s) == 0 && s.st_uid != getuid ()) { |