2 #include "internal/missing.h"
3 #if defined HAVE_DLADDR
6 #if defined HAVE_SYS_PARAM_H
9 static void* stub_options(int argc
, char **argv
);
10 #define ruby_options stub_options
15 stub_options(int argc
, char **argv
)
18 char *xargv
[4] = {NULL
, xflag
};
22 #if defined __CYGWIN__ || defined _WIN32
23 /* GetCommandLineW should contain the accessible path,
24 * use argv[0] as is */
25 #elif defined __linux__
27 char selfexe
[MAXPATHLEN
];
28 ssize_t len
= readlink("/proc/self/exe", selfexe
, sizeof(selfexe
));
30 perror("readlink(\"/proc/self/exe\")");
36 #elif defined HAVE_DLADDR
39 if (!dladdr(stub_options
, &dli
)) {
43 cmd
= (char *)dli
.dli_fname
;
47 #ifndef HAVE_SETPROCTITLE
48 /* argc and argv must be the original */
49 ruby_init_setproctitle(argc
, argv
);
52 /* set script with -x option */
53 /* xargv[0] is NULL not to re-initialize setproctitle again */
55 ret
= ruby_options(3, xargv
);
57 /* set all arguments to ARGV */
58 ruby_set_argv(argc
- 1, argv
+ 1);