mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-03-17 21:38:45 -04:00
fixes to get pid on FreeBSD
This commit is contained in:
@@ -31,6 +31,9 @@
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/thr.h>
|
||||
#endif
|
||||
|
||||
bool Logger::smInitialised = false;
|
||||
Logger *Logger::smInstance = 0;
|
||||
@@ -527,9 +530,17 @@ void Logger::logPrint( bool hex, const char * const file, const int line, const
|
||||
#endif
|
||||
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
|
||||
if (tid < 0 ) // Thread/Process id
|
||||
#else
|
||||
#ifdef HAVE_SYSCALL
|
||||
if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id
|
||||
#endif // HAVE_SYSCALL
|
||||
#endif
|
||||
tid = getpid(); // Process id
|
||||
|
||||
char *logPtr = logString;
|
||||
|
||||
@@ -28,12 +28,26 @@
|
||||
#endif // HAVE_SYS_SYSCALL_H
|
||||
#include "zm_exception.h"
|
||||
#include "zm_utils.h"
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/thr.h>
|
||||
#endif
|
||||
|
||||
class ThreadException : public Exception
|
||||
{
|
||||
private:
|
||||
pid_t pid() {
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
#else
|
||||
tid=syscall(SYS_gettid);
|
||||
#endif
|
||||
return tid;
|
||||
}
|
||||
public:
|
||||
ThreadException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)syscall(SYS_gettid) ) )
|
||||
{
|
||||
ThreadException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) ) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -205,7 +219,15 @@ protected:
|
||||
|
||||
pid_t id() const
|
||||
{
|
||||
return( (pid_t)syscall(SYS_gettid) );
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
#else
|
||||
tid=syscall(SYS_gettid);
|
||||
#endif
|
||||
return tid;
|
||||
}
|
||||
void exit( int status = 0 )
|
||||
{
|
||||
|
||||
@@ -32,8 +32,20 @@ class Timer
|
||||
private:
|
||||
class TimerException : public Exception
|
||||
{
|
||||
private:
|
||||
pid_t pid() {
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
#else
|
||||
tid=syscall(SYS_gettid);
|
||||
#endif
|
||||
return tid;
|
||||
}
|
||||
public:
|
||||
TimerException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)syscall(SYS_gettid) ) )
|
||||
TimerException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user