代码拉取完成,页面将自动刷新
同步操作将从 Josin/cknit 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/**
* Copyright @2019 Josin All Rights Reserved.
* Author: Josin
* Email : xeapplee@gmail.com
*/
#include <ck_task.h>
#include <estring.h>
#include <log.h>
#include <getopt.h>
int main(int argc, char *argv[])
{
int opt;
int oi;
long pid, re;
char *bff, *os = "r:n::";
oi = 0;
static struct option lo[] =
{
{"k", 1, NULL, 'r'},
{"help", 0, NULL, 'n'},
{NULL, 0, NULL, 0 },
};
if ( argc == 1 )
{
goto print_help;
}
while ( ( opt =
getopt_long_only( argc, argv, os, lo, &oi ) ) != -1 )
{
switch (opt)
{
case 'r':
if ( e_memcmp(optarg, E_STRL("start")) == 0 )
{
main_thread();
}
elif ( e_memcmp(optarg, E_STRL("restart")) == 0 )
{
bff = e_data_from_file(PIDFILE, NULL);
if ( bff ) {
errno = 0;
pid = strtol( bff, NULL, 10);
if ( pid != 0 )
{
re = kill( (int)pid, 0);
if ( re == 0 || ( re != -1 || errno == EPERM ) )
{
kill( (int)pid, SIGUSR2);
}
}
sleep(1);
main_thread();
} else {
main_thread();
}
}
elif ( e_memcmp(optarg, E_STRL("stop")) == 0 )
{
bff = e_data_from_file(PIDFILE, NULL);
if ( bff ) {
errno = 0;
pid = strtol( bff, NULL, 10);
if ( pid != 0 ) {
re = kill( (int)pid, 0);
if ( re == 0 || ( re != -1 || errno == EPERM ) )
{
kill((int)strtol(bff, NULL, 10), SIGUSR2);
} else {
fprintf(stdout, "cknit is not running.\n");
}
} else {
fprintf(stdout, "cknit is not running.\n");
}
} else {
fprintf(stdout, "cknit is not running.\n");
}
e_write_to_file(PIDFILE, "");
}
else
{
fprintf(stderr, "cknit --k [restart|start|stop]\n");
}
break;
case 'n':
goto print_help;
default:
break;
}
}
return 0;
print_help:
fprintf(
stdout,
"Usage: cknit [OPTION]... \n"
"A Task tool written in C and manage by APIs "
"\n\n"
"OPTIONs: \n"
" -h, --help Display this help and exit\n"
" -k, --k [restart|start|stop] Restart|Start|Stop cknit\n"
);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。