⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pid.c

📁 读写Smart卡加解密接口的程序
💻 C
字号:
#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <syslog.h>#include <sys/stat.h>#include <unistd.h>#include "usbtoken.h"char *pidfile;void pid_exit(){	if (pidfile) {		unlink(pidfile);		free(pidfile);	}}int pid_init(){	int i;	for (i = 0; i < MAXTOKEN - 1; i++) {		char buffer[1024];		int fd;		snprintf(buffer, sizeof(buffer), PIDFILE, i);		fd = open(buffer, O_CREAT|O_EXCL|O_WRONLY, 0644);		if (fd == -1) {			continue;		}		pidfile = strdup(buffer);		snprintf(buffer, sizeof(buffer), "%d\n", getpid());		write(fd, buffer, strlen(buffer));		close(fd);		usbtoken.slot = i;		atexit(pid_exit);		return USBTOKEN_OK;	}	return USBTOKEN_ERROR;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -