summaryrefslogtreecommitdiff
path: root/src/plugin
diff options
context:
space:
mode:
author杨威 <[email protected]>2023-05-08 20:31:19 +0800
committer杨威 <[email protected]>2023-05-16 17:47:35 +0800
commite725f5c8e14359c6e2d63fff833fc548e7523fd4 (patch)
treecbd8cec7a658d8a5d1097b9ec88e2c904dbbeaa4 /src/plugin
parent7aee7340527eaba27c9f2c770900efe406de0c88 (diff)
🧪 test(inline test): 增加ioctl输出时的打印信息
Diffstat (limited to 'src/plugin')
-rw-r--r--src/plugin/src/plugin.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/plugin/src/plugin.c b/src/plugin/src/plugin.c
index c5236e3..4f77990 100644
--- a/src/plugin/src/plugin.c
+++ b/src/plugin/src/plugin.c
@@ -89,6 +89,7 @@ int stream_register_fun(int funtype,char (*x)(void), int);
*/
+#include <libgen.h>
#include "sapp_api.h"
#include "sapp_private_api.h"
@@ -182,6 +183,7 @@ static void plugin_del_blank_rn(char *data, int max_len)
�����
//add by yw 20150318, reset cwd to exe dir
*****************************************************************************/
+#if 0
static int reset_cwd()
{
char cur_path[1024];
@@ -208,6 +210,29 @@ static int reset_cwd()
}
return 0;
}
+#endif
+
+static int reset_cwd()
+{
+ char path[PATH_MAX];
+ ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path) - 1);
+ if (path_len == -1) {
+ perror("readlink");
+ return -1;
+ }
+ path[path_len] = '\0';
+
+ // ��ȡ��ִ���ļ����ڵ�Ŀ¼
+ char *dir = dirname(path);
+
+ if (chdir(dir) == -1) {
+ perror("chdir");
+ return -1;
+ }
+
+ return 0;
+}
+
/****************************************************************************
������:get_propluginfo_name()