16 #include <sys/types.h>
32 pid_t GetDaemonPid(
void)
40 fd = open(PCSCLITE_RUN_PID, O_RDONLY);
43 char pid_ascii[PID_ASCII_SIZE];
45 (void)read(fd, pid_ascii, PID_ASCII_SIZE);
48 pid = atoi(pid_ascii);
52 Log2(PCSC_LOG_CRITICAL,
"Can't open " PCSCLITE_RUN_PID
": %s",
60 int SendHotplugSignal(
void)
68 Log2(PCSC_LOG_INFO,
"Send hotplug signal to pcscd (pid=%d)", pid);
69 if (kill(pid, SIGUSR1) < 0)
71 Log3(PCSC_LOG_CRITICAL,
"Can't signal pcscd (pid=%d): %s",
72 pid, strerror(errno));
88 #define OPENCT_FILE "/var/run/openct/status"
89 int CheckForOpenCT(
void)
95 Log1(PCSC_LOG_CRITICAL,
"File " OPENCT_FILE " found. Remove OpenCT and try again");
106 long int time_sub(
struct timeval *a,
struct timeval *b)
109 r.tv_sec = a -> tv_sec - b -> tv_sec;
110 r.tv_usec = a -> tv_usec - b -> tv_usec;
114 r.tv_usec += 1000000;
117 return r.tv_sec * 1000000 + r.tv_usec;
120 int ThreadCreate(pthread_t * pthThread,
int attributes,
121 PCSCLITE_THREAD_FUNCTION(pvFunction), LPVOID pvArg)
126 ret = pthread_attr_init(&attr);
130 ret = pthread_attr_setdetachstate(&attr,
131 attributes & THREAD_ATTR_DETACHED ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
134 (void)pthread_attr_destroy(&attr);
138 ret = pthread_create(pthThread, &attr, pvFunction, pvArg);
142 ret = pthread_attr_destroy(&attr);
#define OPENCT_FILE
Check is OpenCT is running and display a critical message if it is.
This handles abstract system level calls.
int SYS_Sleep(int)
Makes the current process sleep for some seconds.
long int time_sub(struct timeval *a, struct timeval *b)
return the difference (as long int) in µs between 2 struct timeval r = a - b
This keeps a list of defines for pcsc-lite.