如何通过长尾关键词覆盖c – ETXTBSY错误?
- 内容介绍
- 文章标签
- 相关推荐
本文共计263个文字,预计阅读时间需要2分钟。
我需要写入当前正在执行的可执行文件,但我无法打开它进行写入。例如:
我需要写入正在执行的可执行文件,但我无法打开它进行写入.例如:#include <stdio.h> #include <fcntl.h> int main(int argc, char **argv) { int fd = open(argv[0], O_RDWR); if (fd == -1) perror(NULL); return 0; }
% uname -rs FreeBSD 8.0-STABLE % ./example_ETXTBSY Text file busy
在Linux中有7万个ETXTBSY,但是,是否可以覆盖此错误?
附:
我不是想写病毒.
#include <stdio.h> #include <fcntl.h> #include <sys/stat.h> int main(int argc, char **argv) { unlink(argv[0]); int fd = open(argv[0], O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); if (fd == -1) perror(NULL); return 0; }
如果您尝试访问实际运行过程,最好的选择是ptrace().
(已编辑添加模式位.)
本文共计263个文字,预计阅读时间需要2分钟。
我需要写入当前正在执行的可执行文件,但我无法打开它进行写入。例如:
我需要写入正在执行的可执行文件,但我无法打开它进行写入.例如:#include <stdio.h> #include <fcntl.h> int main(int argc, char **argv) { int fd = open(argv[0], O_RDWR); if (fd == -1) perror(NULL); return 0; }
% uname -rs FreeBSD 8.0-STABLE % ./example_ETXTBSY Text file busy
在Linux中有7万个ETXTBSY,但是,是否可以覆盖此错误?
附:
我不是想写病毒.
#include <stdio.h> #include <fcntl.h> #include <sys/stat.h> int main(int argc, char **argv) { unlink(argv[0]); int fd = open(argv[0], O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); if (fd == -1) perror(NULL); return 0; }
如果您尝试访问实际运行过程,最好的选择是ptrace().
(已编辑添加模式位.)

