1 Star 0 Fork 28

microinfo / bolt

forked from liexusong / bolt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
utils.c 503 Bytes
一键复制 编辑 原始数据 按行查看 历史
liexusong 提交于 2015-08-28 00:25 . add log feature
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
int
bolt_utils_file_exists(char *path)
{
return access((const char *)path, F_OK) == 0;
}
void
bolt_daemonize()
{
int fd;
if (fork() != 0) {
exit(0);
}
setsid();
if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO) {
close(fd);
}
}
}
1
https://gitee.com/microinfo/bolt.git
git@gitee.com:microinfo/bolt.git
microinfo
bolt
bolt
master

搜索帮助