Linux: set OS process name to match -N argument or argv[0]
This commit is contained in:
parent
113e0aa184
commit
1788703a42
|
@ -1171,6 +1171,9 @@ static int run_from_cmd_line(int argc, char *_argv[],
|
|||
sprog = prog;
|
||||
|
||||
(void)scheme_set_run_cmd(sprog);
|
||||
#ifdef CAN_SET_OS_PROCESS_NAME
|
||||
set_os_process_name(sprog);
|
||||
#endif
|
||||
|
||||
if (no_compiled)
|
||||
scheme_set_compiled_file_paths(scheme_make_null());
|
||||
|
|
|
@ -152,6 +152,25 @@ extern Scheme_Object *scheme_initialize(Scheme_Env *env);
|
|||
|
||||
#define BANNER scheme_banner()
|
||||
|
||||
/*========================================================================*/
|
||||
/* OS process name */
|
||||
/*========================================================================*/
|
||||
|
||||
#if defined(linux)
|
||||
# include <sys/prctl.h>
|
||||
# ifdef PR_SET_NAME
|
||||
# define CAN_SET_OS_PROCESS_NAME 1
|
||||
void set_os_process_name(char *sprog)
|
||||
{
|
||||
int i = strlen(sprog) - 1;
|
||||
while (i && (sprog[i - 1] != '/')) {
|
||||
--i;
|
||||
}
|
||||
prctl(PR_SET_NAME, sprog + i);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*========================================================================*/
|
||||
/* command-line parsing */
|
||||
/*========================================================================*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user