僵尸进程:
11063 root 0 Z [sh] 11068 root 0 Z [sh] 11072 root 0 Z [sh] 11075 root 0 Z [sh] 11078 root 0 Z [sh] 11080 root 0 Z [sh] 11082 root 0 Z [sh] 11084 root 0 Z [sh]
解决:
popen之后添加signal(SIGCHLD, SIG_IGN);需要包含#include <signal.h>
#include <stdio.h> #include <signal.h> #include <string.h> int main(int argc, char *argv[]) { char payload[1024] = {0}; FILE *fp; fp = popen("exec /usr/bin/lua /tmp/abc.lua", "r"); signal(SIGCHLD, SIG_IGN); if (NULL == fp) return -1; fgets(payload, 1024, fp); if (payload[strlen(payload) - 1] == '\n') { payload[strlen(payload) - 1] = '\0'; } fclose(fp); }
参考:https://www.codeleading.com/article/82835694707/