2 #if defined HAVE_DLADDR
5 #if defined HAVE_SYS_PARAM_H
8 static void* stub_options(int argc
, char **argv
);
9 #define ruby_options stub_options
14 stub_options(int argc
, char **argv
)
17 char *xargv
[4] = {NULL
, xflag
};
21 #if defined __CYGWIN__ || defined _WIN32
22 /* GetCommandLineW should contain the accessible path,
23 * use argv[0] as is */
24 #elif defined __linux__
26 char selfexe
[MAXPATHLEN
];
27 ssize_t len
= readlink("/proc/self/exe", selfexe
, sizeof(selfexe
));
29 perror("readlink(\"/proc/self/exe\")");
35 #elif defined HAVE_DLADDR
38 if (!dladdr(stub_options
, &dli
)) {
42 cmd
= (char *)dli
.dli_fname
;
46 #ifndef HAVE_SETPROCTITLE
47 /* argc and argv must be the original */
48 ruby_init_setproctitle(argc
, argv
);
51 /* set script with -x option */
52 /* xargv[0] is NULL not to re-initialize setproctitle again */
54 ret
= ruby_options(3, xargv
);
56 /* set all arguments to ARGV */
57 ruby_set_argv(argc
- 1, argv
+ 1);