Ld preload 为什么';当我在nginx中使用ldu PRELOAD捕获open()时,它是否工作得很好?

Ld preload 为什么';当我在nginx中使用ldu PRELOAD捕获open()时,它是否工作得很好?,ld-preload,Ld Preload,我想使用LD_PRELOAD捕获nginx的open()调用来记录nginx打开的文件,但它似乎不起作用。 我搜索了nginx的源代码,我认为它使用函数open()来打开文件。 我使用与其他人相同的方法钩住open(),它在正常测试中运行良好,就像这样 #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <errno.h

我想使用LD_PRELOAD捕获nginx的open()调用来记录nginx打开的文件,但它似乎不起作用。 我搜索了nginx的源代码,我认为它使用函数open()来打开文件。

我使用与其他人相同的方法钩住open(),它在正常测试中运行良好,就像这样

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

int main() {
  int fd = open("config.c",O_RDWR);
  printf("%d\n",fd);
  char buf[100] = {0};
  ssize_t t = read(fd, buf, 10);
  printf("buf:%s\n",buf);
  return 0;
}
这行不通

任何人都可以教我为什么它在nginx中不起作用?我应该试试什么

谢谢

LD_PRELOAD=./myopen.so nginx