--- freem/src/init.c 2025/03/24 04:44:55 1.8 +++ freem/src/init.c 2025/04/13 04:22:43 1.11 @@ -1,5 +1,5 @@ /* - * $Id: init.c,v 1.8 2025/03/24 04:44:55 snw Exp $ + * $Id: init.c,v 1.11 2025/04/13 04:22:43 snw Exp $ * FreeM initialization * * @@ -24,6 +24,15 @@ * along with FreeM. If not, see . * * $Log: init.c,v $ + * Revision 1.11 2025/04/13 04:22:43 snw + * Fix snprintf calls + * + * Revision 1.10 2025/04/10 01:24:38 snw + * Remove C++ style comments + * + * Revision 1.9 2025/04/03 16:58:34 snw + * Make error message for shm_init error during initialization more friendly + * * Revision 1.8 2025/03/24 04:44:55 snw * Don't call ttyname on OS/2 * @@ -179,7 +188,15 @@ short init (char *namespace_name) retval = shm_init (shm_init_size); if (retval == SHMS_GET_ERR) { - fprintf (stderr, "init: error initializing shared memory [errno %d]\r\n", errno); + if (errno != 13) { + fprintf (stderr, "init: error initializing shared memory [errno %d]\r\n", errno); + } + else { + fprintf (stderr, "init: error attaching to environment -- does your user belong to the group that owns environment '%s'?\r\n", shm_env); + } + if (run_daemon == FALSE) { + set_io (UNIX); + } exit (1); } @@ -230,7 +247,7 @@ void init_process (void) { pid = getpid (); /* get $J = process ID */ umask (0); /* protection bits mask to full rights */ - snprintf (fp_conversion, 9, "%%.%df\201", DBL_DIG); + snprintf (fp_conversion, sizeof (fp_conversion) - 1, "%%.%df\201", DBL_DIG); if (fp_mode) { zprecise = DBL_DIG; @@ -439,7 +456,7 @@ void init_readline (void) pw_buf = (char *) calloc (strlen(pw->pw_dir) + 1, sizeof(char)); strcpy (pw_buf, pw->pw_dir); - snprintf (history_file, 256, "%s/.freem_history", pw_buf); + snprintf (history_file, sizeof (history_file) - 1, "%s/.freem_history", pw_buf); free (pw_buf); @@ -532,7 +549,7 @@ void init_mwapi (void) gtk_init (0, NULL); } */ - //TODO: init Motif/libXt + /* TODO: init Motif/libXt */ } #else void init_mwapi (void) @@ -647,7 +664,7 @@ void cleanup (void) int ch; /* remove this job's entry from ^$JOB SSVN */ - snprintf (k_buf, 255, "^$JOB\202%d\201", pid); + snprintf (k_buf, sizeof (k_buf) - 1, "^$JOB\202%d\201", pid); symtab_shm (kill_sym, k_buf, " \201"); reset_terminal ();