Diff for /freem/src/init.c between versions 1.9 and 1.13

version 1.9, 2025/04/03 16:58:34 version 1.13, 2025/04/17 14:34:27
Line 24 Line 24
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.   *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *   *
  *   $Log$   *   $Log$
    *   Revision 1.13  2025/04/17 14:34:27  snw
    *   Further logging improvements
    *
    *   Revision 1.12  2025/04/15 14:39:06  snw
    *   Further improvements to logging
    *
    *   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   *   Revision 1.9  2025/04/03 16:58:34  snw
  *   Make error message for shm_init error during initialization more friendly   *   Make error message for shm_init error during initialization more friendly
  *   *
Line 86 Line 98
 #include "jobtab.h"  #include "jobtab.h"
 #include "datatypes.h"  #include "datatypes.h"
 #include "objects.h"  #include "objects.h"
   #include "log.h"
   
 #ifdef HAVE_LIBREADLINE  #ifdef HAVE_LIBREADLINE
 #  if defined(HAVE_READLINE_READLINE_H)  #  if defined(HAVE_READLINE_READLINE_H)
Line 159  void init_mwapi(void); Line 172  void init_mwapi(void);
 short init (char *namespace_name)   short init (char *namespace_name) 
 {  {
     short retval;      short retval;
       int log_level;
           
       init_log ();
     init_process ();      init_process ();
     init_devtable ();      init_devtable ();
     init_signals ();      init_signals ();
Line 183  short init (char *namespace_name) Line 198  short init (char *namespace_name)
   
     if (retval == SHMS_GET_ERR) {      if (retval == SHMS_GET_ERR) {
         if (errno != 13) {          if (errno != 13) {
             fprintf (stderr, "init:  error initializing shared memory [errno %d]\r\n", errno);              logprintf (FM_LOG_FATAL, "init:  error initializing shared memory (error code %d [%s])", errno, strerror (errno));
         }          }
         else {          else {
             fprintf (stderr, "init:  error attaching to environment -- does your user belong to the group that owns environment '%s'?\r\n", shm_env);              logprintf (FM_LOG_FATAL, "init:  error attaching to environment -- does your user belong to the group that owns environment '%s'?", shm_env);
         }  
         if (run_daemon == FALSE) {  
             set_io (UNIX);  
         }          }
         exit (1);  
     }      }
   
     symtab_init ();      symtab_init ();
Line 200  short init (char *namespace_name) Line 211  short init (char *namespace_name)
     set_namespace (namespace_name, FALSE);      set_namespace (namespace_name, FALSE);
   
     if (first_process) {      if (first_process) {
         fprintf (stderr, "init:  we are the first process in the environment (pid %d)\r\n", pid);          log_level = FM_LOG_INFO;
       }
       else {
           log_level = FM_LOG_DEBUG;
       }
       
       if (first_process) {
           logprintf (log_level, "init:  we are the first process in the environment (pid %d)", pid);
     }      }
   
     if (first_process) fprintf (stderr, "init:  initializing job table\r\n");      logprintf (log_level, "init:  initializing job table");
     jobtab_init ();      jobtab_init ();
   
     if (first_process) fprintf (stderr, "init:  adding job to job table\r\n");      logprintf (log_level, "init:  adding job to job table");
     job_init (FALSE);      job_init (FALSE);
   
     if (first_process) fprintf (stderr, "init:  initializing structured system variables\r\n");      logprintf (log_level, "init:  initializing structured system variables");
     init_ssvn ();      init_ssvn ();
   
     if (first_process) fprintf (stderr, "init:  initializing terminal\r\n");      logprintf (log_level, "init:  initializing terminal");
     init_terminal ();      init_terminal ();
   
     if (first_process) fprintf (stderr, "init:  initializing asynchronous events\r\n");      logprintf (log_level, "init:  initializing asynchronous events");
     evt_init ();      evt_init ();
   
     if (first_process) fprintf (stderr, "init:  initializing debugger\r\n");      logprintf (log_level, "init:  initializing debugger");
     dbg_init ();          dbg_init ();    
   
     if (first_process) fprintf (stderr, "init:  initializing error stack\r\n");      logprintf (log_level, "init:  initializing error stack");
     init_estack();      init_estack();
           
     etrap[0] = EOL;      etrap[0] = EOL;
Line 241  void init_process (void) Line 259  void init_process (void)
 {  {
     pid = getpid ();            /* get $J = process ID */      pid = getpid ();            /* get $J = process ID */
     umask (0);              /* protection bits mask to full rights */      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) {      if (fp_mode) {
         zprecise = DBL_DIG;          zprecise = DBL_DIG;
Line 450  void init_readline (void) Line 468  void init_readline (void)
     pw_buf = (char *) calloc (strlen(pw->pw_dir) + 1, sizeof(char));      pw_buf = (char *) calloc (strlen(pw->pw_dir) + 1, sizeof(char));
     strcpy (pw_buf, pw->pw_dir);      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);      free (pw_buf);
   
Line 543  void init_mwapi (void) Line 561  void init_mwapi (void)
         gtk_init (0, NULL);          gtk_init (0, NULL);
     }      }
     */      */
     //TODO: init Motif/libXt      /* TODO: init Motif/libXt */
 }  }
 #else  #else
 void init_mwapi (void)  void init_mwapi (void)
Line 658  void cleanup (void) Line 676  void cleanup (void)
     int ch;      int ch;
   
     /* remove this job's entry from ^$JOB SSVN */      /* 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");      symtab_shm (kill_sym, k_buf, " \201");
           
     reset_terminal ();      reset_terminal ();

Removed from v.1.9  
changed lines
  Added in v.1.13


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>