在程序自动升级的时候需要自己重新启动自己
示例代码:
zengming@linux-eshv:~/test> g++ main.cpp
zengming@linux-eshv:~/test> ./a.out 1
Running: ./a.out 1
Running: ./a.out 2
Running: ./a.out 3
^C
程序员群:31843264
阅读(1850) | 评论(0) | 转发(0) |
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
示例代码:
点击(此处)折叠或打开
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- int main(int argc, char **argv)
- {
- char buf[32] = {};
- char *exec_argv[] = { argv[0], buf, 0 };
- int count = argc > 1 ? atoi(argv[1]) : 0;
-
- printf("Running: %s %d\n", argv[0], count);
- snprintf(buf, sizeof(buf), "%d", count+1);
- sleep(5);
-
- execv("/proc/self/exe", exec_argv);
-
- /* NOT REACHED */
- return 0;
- }
zengming@linux-eshv:~/test> ./a.out 1
Running: ./a.out 1
Running: ./a.out 2
Running: ./a.out 3
^C
程序员群:31843264
给主人留下些什么吧!~~
评论热议