summaryrefslogtreecommitdiffstats
path: root/tdm/backend/dm.c
diff options
context:
space:
mode:
Diffstat (limited to 'tdm/backend/dm.c')
-rw-r--r--tdm/backend/dm.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/tdm/backend/dm.c b/tdm/backend/dm.c
index 605f0b1c4..9168b88b5 100644
--- a/tdm/backend/dm.c
+++ b/tdm/backend/dm.c
@@ -34,6 +34,8 @@ from the copyright holder.
* display manager
*/
+#include <tqglobal.h>
+
#include "dm.h"
#include "dm_auth.h"
#include "dm_error.h"
@@ -51,6 +53,12 @@ from the copyright holder.
# include <sys/vt.h>
#endif
+#ifdef HAVE_PTHREAD_SETNAME_NP
+#define _GNU_SOURCE
+#define __BSD_VISIBLE 1
+#include <pthread.h>
+#endif /* pthread_setname_np() */
+
// Limited by the number of VTs configured into the kernel or 256, whichever is less
#define MAX_VT_NUMBER 48
@@ -66,7 +74,8 @@ static void MainLoop( void );
static int signalFds[2];
-#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE)
+#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE) && \
+ !defined(HAVE_PTHREAD_SETNAME_NP)
static char *Title;
static int TitleLen;
#endif
@@ -104,7 +113,7 @@ main( int argc, char **argv )
if (!StrDup( &progpath, argv[0] ))
Panic( "Out of memory" );
} else
-#ifdef __linux__
+#ifdef Q_OS_LINUX
{
/* note that this will resolve symlinks ... */
int len;
@@ -114,6 +123,16 @@ main( int argc, char **argv )
if (!StrNDup( &progpath, fullpath, len ))
Panic( "Out of memory" );
}
+#elif defined(Q_OS_SOLARIS)
+ {
+ /* note that this will resolve symlinks ... */
+ int len;
+ char fullpath[PATH_MAX];
+ if ((len = readlink( "/proc/self/path/a.out", fullpath, sizeof(fullpath) )) < 0)
+ Panic( "Invoke with full path specification or mount /proc" );
+ if (!StrNDup( &progpath, fullpath, len ))
+ Panic( "Out of memory" );
+ }
#else
# if 0
Panic( "Must be invoked with full path specification" );
@@ -161,7 +180,8 @@ main( int argc, char **argv )
#endif
prog = strrchr( progpath, '/' ) + 1;
-#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE)
+#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE) && \
+ !defined(HAVE_PTHREAD_SETNAME_NP)
Title = argv[0];
TitleLen = (argv[argc - 1] + strlen( argv[argc - 1] )) - Title;
#endif
@@ -1685,7 +1705,8 @@ UnlockPidFile( void )
void
SetTitle( const char *name )
{
-#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE)
+#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE) && \
+ !defined(HAVE_PTHREAD_SETNAME_NP)
char *p;
int left;
#endif
@@ -1694,6 +1715,8 @@ SetTitle( const char *name )
ReInitErrorLog();
#ifdef HAVE_SETPROCTITLE
setproctitle( "%s", name );
+#elif defined(HAVE_PTHREAD_SETNAME_NP)
+ pthread_setname_np(pthread_self(), name);
#elif !defined(NOXDMTITLE)
p = Title;
left = TitleLen;