Minor improvement of get_prog_name().

This commit is contained in:
ManoloFLTK 2022-04-21 07:06:18 +02:00
parent 2b904ccef4
commit 24885b3810

View File

@ -979,19 +979,19 @@ static Fl_Window *calc_transient_parent(int &center_x, int &center_y) {
}
static char *get_prog_name() {
static const char *get_prog_name() {
pid_t pid = getpid();
char fname[100];
sprintf(fname, "/proc/%u/cmdline", pid);
FILE *in = fopen(fname, "r");
if (in) {
static char line[200];
char *p = fgets(line, sizeof(line), in);
const char *p = fgets(line, sizeof(line), in);
fclose(in);
p = strrchr(line, '/'); if (!p) p = line; else p++;
return p;
}
return NULL;
return "unknown";
}