1: /*
2: * $Id: init.c,v 1.15 2025/05/16 04:02:14 snw Exp $
3: * FreeM initialization
4: *
5: *
6: * Author: Serena Willis <snw@coherent-logic.com>
7: * Copyright (C) 1998 MUG Deutschland
8: * Copyright (C) 2020, 2025 Coherent Logic Development LLC
9: *
10: *
11: * This file is part of FreeM.
12: *
13: * FreeM is free software: you can redistribute it and/or modify
14: * it under the terms of the GNU Affero Public License as published by
15: * the Free Software Foundation, either version 3 of the License, or
16: * (at your option) any later version.
17: *
18: * FreeM is distributed in the hope that it will be useful,
19: * but WITHOUT ANY WARRANTY; without even the implied warranty of
20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: * GNU Affero Public License for more details.
22: *
23: * You should have received a copy of the GNU Affero Public License
24: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
25: *
26: * $Log: init.c,v $
27: * Revision 1.15 2025/05/16 04:02:14 snw
28: * Make FreeM build on macOS on Apple Silicon
29: *
30: * Revision 1.14 2025/04/20 03:13:17 snw
31: * Updates to init_execution_context
32: *
33: * Revision 1.13 2025/04/17 14:34:27 snw
34: * Further logging improvements
35: *
36: * Revision 1.12 2025/04/15 14:39:06 snw
37: * Further improvements to logging
38: *
39: * Revision 1.11 2025/04/13 04:22:43 snw
40: * Fix snprintf calls
41: *
42: * Revision 1.10 2025/04/10 01:24:38 snw
43: * Remove C++ style comments
44: *
45: * Revision 1.9 2025/04/03 16:58:34 snw
46: * Make error message for shm_init error during initialization more friendly
47: *
48: * Revision 1.8 2025/03/24 04:44:55 snw
49: * Don't call ttyname on OS/2
50: *
51: * Revision 1.7 2025/03/24 04:05:36 snw
52: * Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2
53: *
54: * Revision 1.6 2025/03/09 19:14:25 snw
55: * First phase of REUSE compliance and header reformat
56: *
57: *
58: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
59: * SPDX-License-Identifier: AGPL-3.0-or-later
60: **/
61:
62: #include <stdio.h>
63: #include <stdlib.h>
64: #include <string.h>
65: #include <unistd.h>
66: #include <limits.h>
67: #include <sys/types.h>
68: #include <sys/stat.h>
69: #include <pwd.h>
70: #include <time.h>
71: #include <errno.h>
72: #include <sys/ioctl.h>
73:
74: #if !defined(__APPLE__) && !defined(__gnu_hurd__) && !defined(EMSCRIPTEN)
75: # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__AMIGA)
76: # include <termios.h>
77: # if !defined(__AMIGA)
78: # define TCGETA TIOCGETA
79: # define TCSETA TIOCSETA
80: # endif
81: # define termio termios
82: # else
83: # if !defined(MSDOS)
84: # include <termio.h>
85: # endif
86: # endif
87: #else
88: # include <termios.h>
89: #endif
90:
91: #if defined(__APPLE__)
92: # define termio termios
93: # define TCGETA TIOCGETA
94: # define TCSETA TIOCSETA
95: #endif
96:
97: #include "config.h"
98:
99: #if defined(HAVE_MWAPI_MOTIF)
100: # include <Xm/Xm.h>
101: #endif
102:
103: #include "mpsdef.h"
104: #include "transact.h"
105: #include "namespace.h"
106: #include "events.h"
107: #include "mdebug.h"
108: #include "shmmgr.h"
109: #include "locktab.h"
110: #include "jobtab.h"
111: #include "datatypes.h"
112: #include "objects.h"
113: #include "log.h"
114:
115: #ifdef HAVE_LIBREADLINE
116: # if defined(HAVE_READLINE_READLINE_H)
117: # include <readline/readline.h>
118: # elif defined(HAVE_READLINE_H)
119: # include <readline.h>
120: # else /* !defined(HAVE_READLINE_H) */
121: extern char *readline ();
122: # endif /* !defined(HAVE_READLINE_H) */
123: char *cmdline = NULL;
124: #else /* !defined(HAVE_READLINE_READLINE_H) */
125: /* no readline */
126: #endif /* HAVE_LIBREADLINE */
127:
128: #ifdef HAVE_READLINE_HISTORY
129: # if defined(HAVE_READLINE_HISTORY_H)
130: # include <readline/history.h>
131: # elif defined(HAVE_HISTORY_H)
132: # include <history.h>
133: # else /* !defined(HAVE_HISTORY_H) */
134: extern void add_history ();
135: extern int write_history ();
136: extern int read_history ();
137: # endif /* defined(HAVE_READLINE_HISTORY_H) */
138: /* no history */
139: #endif /* HAVE_READLINE_HISTORY */
140:
141: #if defined(HAVE_WIRINGPI_H)
142: # include <wiringPi.h>
143: #endif
144:
145: #if !defined(PATH_MAX) && defined(_SCO_DS)
146: # define PATH_MAX 4096
147: #endif
148:
149: #if !defined(PATH_MAX) && defined(__gnu_hurd__)
150: # define PATH_MAX 1024
151: #endif
152:
153: #if !defined(PATH_MAX) && defined(__sun__)
154: # include <limits.h>
155: #endif
156:
157: #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
158: # include <sys/syslimits.h>
159: #endif
160:
161: #define SHMKEY 0x990120
162: #define SHMSIZ 1048576
163:
164: void init_process(void);
165: void init_devtable(void);
166: void init_signals(void);
167: void init_timezone(void);
168: void init_freem_path(void);
169:
170: #if defined(HAVE_LIBREADLINE)
171: void init_readline(void);
172: #endif
173:
174: void init_execution_context(void);
175: void init_io(void);
176: void init_random_number(void);
177: void init_ztrap(void);
178: void init_ssvn(void);
179: void init_terminal(void);
180: void init_estack(void);
181:
182: void init_mwapi(void);
183:
184: short init (char *namespace_name)
185: {
186: short retval;
187: int log_level;
188:
189: init_log ();
190: init_process ();
191: init_devtable ();
192: init_signals ();
193: init_freem_path ();
194: init_timezone ();
195:
196: #if defined(HAVE_LIBREADLINE)
197: init_readline ();
198: #endif
199:
200: init_execution_context ();
201:
202: if (run_daemon == FALSE) {
203: init_io ();
204: }
205:
206: init_random_number ();
207: init_ztrap ();
208:
209: retval = shm_init (shm_init_size);
210:
211: if (retval == SHMS_GET_ERR) {
212: if (errno != 13) {
213: logprintf (FM_LOG_FATAL, "init: error initializing shared memory (error code %d [%s])", errno, strerror (errno));
214: }
215: else {
216: logprintf (FM_LOG_FATAL, "init: error attaching to environment -- does your user belong to the group that owns environment '%s'?", shm_env);
217: }
218: }
219:
220: symtab_init ();
221: tp_init ();
222:
223: set_namespace (namespace_name, FALSE);
224:
225: if (first_process) {
226: log_level = FM_LOG_INFO;
227: }
228: else {
229: log_level = FM_LOG_DEBUG;
230: }
231:
232: if (first_process) {
233: logprintf (log_level, "init: we are the first process in the environment (pid %d)", pid);
234: }
235:
236: logprintf (log_level, "init: initializing job table");
237: jobtab_init ();
238:
239: logprintf (log_level, "init: adding job to job table");
240: job_init (FALSE);
241:
242: logprintf (log_level, "init: initializing structured system variables");
243: init_ssvn ();
244:
245: logprintf (log_level, "init: initializing terminal");
246: init_terminal ();
247:
248: logprintf (log_level, "init: initializing asynchronous events");
249: evt_init ();
250:
251: logprintf (log_level, "init: initializing debugger");
252: dbg_init ();
253:
254: logprintf (log_level, "init: initializing error stack");
255: init_estack();
256:
257: etrap[0] = EOL;
258: ecode[0] = EOL;
259: estack = 0;
260:
261: init_mwapi();
262:
263: if (merr () == OK) {
264: return TRUE;
265: }
266:
267: return FALSE;
268: }
269:
270: void init_process (void)
271: {
272: pid = getpid (); /* get $J = process ID */
273: umask (0); /* protection bits mask to full rights */
274: snprintf (fp_conversion, sizeof (fp_conversion) - 1, "%%.%df\201", DBL_DIG);
275:
276: if (fp_mode) {
277: zprecise = DBL_DIG;
278: }
279: else {
280: zprecise = 100;
281: }
282: }
283:
284: void init_devtable (void)
285: {
286: register int i;
287: register int j;
288:
289: for (j = 0; j <= MAXDEV; j++) { /* init. translation tables */
290:
291: for (i = 0; i < 256; i++) {
292: G0I[j][i] = (char) i;
293: G0O[j][i] = (char) i;
294: G1I[j][i] = (char) i;
295: G1O[j][i] = (char) i;
296: }
297:
298: G0I[j][UNSIGN (EOL)] = NUL;
299: G0O[j][UNSIGN (EOL)] = NUL;
300: G1I[j][UNSIGN (EOL)] = NUL;
301: G1O[j][UNSIGN (EOL)] = NUL;
302: G0I[j][UNSIGN (DELIM)] = NUL;
303: G0O[j][UNSIGN (DELIM)] = NUL;
304: G1I[j][UNSIGN (DELIM)] = NUL;
305: G1O[j][UNSIGN (DELIM)] = NUL;
306: G0I[j][256] = EOL;
307: G0O[j][256] = EOL;
308: G1I[j][256] = EOL;
309: G1O[j][256] = EOL;
310:
311: }
312:
313: #ifdef SCO
314: #ifndef HACK_NOXLATE
315: G0I[HOME][245] = 64;
316: G0O[HOME][64] = 245; /* Paragraph */
317: G0I[HOME][142] = 91;
318: G0O[HOME][91] = 142; /* A umlaut */
319: G0I[HOME][153] = 92;
320: G0O[HOME][92] = 153; /* O umlaut */
321: G0I[HOME][154] = 93;
322: G0O[HOME][93] = 154; /* U umlaut */
323: G0I[HOME][132] = 123;
324: G0O[HOME][123] = 132; /* a umlaut */
325: G0I[HOME][148] = 124;
326: G0O[HOME][124] = 148; /* o umlaut */
327: G0I[HOME][129] = 125;
328: G0O[HOME][125] = 129; /* u umlaut */
329: G0I[HOME][225] = 126;
330: G0O[HOME][126] = 225; /* sharp s */
331: #endif/*HACK_NOXLATE*/
332:
333: /* DEC Special graphics */
334: G1I[HOME][254] = 96;
335: G1O[HOME][96] = 254; /* diamond */
336: G1I[HOME][176] = 97;
337: G1O[HOME][97] = 176; /* checker board */
338: G1I[HOME][241] = 99;
339: G1O[HOME][99] = 241; /* FF */
340: G1I[HOME][242] = 100;
341: G1O[HOME][100] = 242; /* CR */
342: G1I[HOME][243] = 101;
343: G1O[HOME][101] = 243; /* LF */
344: G1I[HOME][248] = 102;
345: G1O[HOME][102] = 248; /* degree sign */
346: G1I[HOME][241] = 103;
347: G1O[HOME][103] = 241; /* plus minus */
348: G1I[HOME][244] = 104;
349: G1O[HOME][104] = 244; /* NL */
350: G1I[HOME][251] = 105;
351: G1O[HOME][105] = 251; /* VT */
352: G1I[HOME][217] = 106;
353: G1O[HOME][106] = 217; /* lower right corner */
354: G1I[HOME][191] = 107;
355: G1O[HOME][107] = 191; /* upper right corner */
356: G1I[HOME][218] = 108;
357: G1O[HOME][108] = 218; /* upper left corner */
358: G1I[HOME][192] = 109;
359: G1O[HOME][109] = 192; /* lower left corner */
360: G1I[HOME][197] = 110;
361: G1O[HOME][110] = 197; /* cross */
362: G1I[HOME][200] = 111;
363: G1O[HOME][111] = 200; /* linescan 5 */
364: G1I[HOME][201] = 112;
365: G1O[HOME][112] = 201; /* linescan 4 */
366: G1I[HOME][196] = 113;
367: G1O[HOME][113] = 196; /* linescan 3 */
368: G1I[HOME][202] = 114;
369: G1O[HOME][114] = 202; /* linescan 2 */
370: G1I[HOME][203] = 115;
371: G1O[HOME][115] = 203; /* linescan 1 */
372: G1I[HOME][195] = 116;
373: G1O[HOME][116] = 195; /* left junction */
374: G1I[HOME][180] = 117;
375: G1O[HOME][117] = 180; /* right junction */
376: G1I[HOME][193] = 118;
377: G1O[HOME][118] = 193; /* lower junction */
378: G1I[HOME][194] = 119;
379: G1O[HOME][119] = 194; /* upper junction */
380: G1I[HOME][179] = 120;
381: G1O[HOME][120] = 179; /* vertival bar */
382: G1I[HOME][243] = 121;
383: G1O[HOME][121] = 243; /* lower equals */
384: G1I[HOME][242] = 122;
385: G1O[HOME][122] = 242; /* greater equals */
386: G1I[HOME][227] = 123;
387: G1O[HOME][123] = 227; /* pi */
388: G1I[HOME][246] = 124;
389: G1O[HOME][124] = 246; /* not equals */
390: G1I[HOME][128] = 125;
391: G1O[HOME][125] = 128; /* euro sign */
392: G1I[HOME][250] = 126;
393: G1O[HOME][126] = 250; /* centered dot */
394: #endif /* SCO */
395: }
396:
397: void init_signals (void)
398: {
399: sig_init ();
400: }
401:
402: void init_timezone (void)
403: {
404:
405: struct tm lt;
406: struct tm gt;
407:
408: unsigned long gmt;
409: unsigned long lmt;
410:
411: long clock;
412:
413: #if defined(__CYGWIN__)
414: tzset (); /* may be required in order */
415: /* to guarantee _timezone set */
416: #else
417:
418: clock = time (0L);
419: lt = *localtime (&clock);
420: gt = *gmtime (&clock);
421:
422: /* This is awkward but I think it is portable: steve_morris */
423: gmt = gt.tm_year * 365;
424: gmt = (gmt + gt.tm_yday) * 24;
425: gmt = (gmt + gt.tm_hour) * 60;
426: gmt = (gmt + gt.tm_min);
427:
428: lmt = lt.tm_year * 365;
429: lmt = (lmt + lt.tm_yday) * 24;
430: lmt = (lmt + lt.tm_hour) * 60;
431: lmt = (lmt + lt.tm_min);
432:
433: FreeM_timezone = (gmt - lmt) * 60;
434: tzoffset = -FreeM_timezone;
435:
436: #endif /* __CYGWIN__ */
437:
438:
439: }
440:
441: void init_freem_path (void)
442: {
443:
444: if((freem_path = malloc(PATH_MAX + 1)) == NULL) {
445: fprintf(stderr, "Can't allocate freem_path. Exiting.");
446:
447: exit(1);
448: }
449:
450: freem_path[0] = NUL;
451:
452: /* check where I'm being executed from */
453: #ifdef __linux__
454: readlink ("/proc/self/exe", freem_path, PATH_MAX);
455: #endif
456: #ifdef __FreeBSD__
457: readlink ("/proc/curproc/file", freem_path, PATH_MAX);
458: #endif
459: #ifdef __sun
460: readlink ("/proc/self/path/a.out", freem_path, PATH_MAX);
461: #endif
462:
463: if(freem_path[0] == NUL) {
464: /* we don't know where we came from */
465: }
466:
467: getcwd (curdir, PATHLEN);
468: stcnv_c2m (curdir);
469:
470: }
471:
472: #if defined(HAVE_LIBREADLINE)
473: void init_readline (void)
474: {
475: uid_t uid = geteuid ();
476: struct passwd *pw = getpwuid (uid);
477: char *pw_buf;
478:
479: pw_buf = (char *) calloc (strlen(pw->pw_dir) + 1, sizeof(char));
480: strcpy (pw_buf, pw->pw_dir);
481:
482: snprintf (history_file, sizeof (history_file) - 1, "%s/.freem_history", pw_buf);
483:
484: free (pw_buf);
485:
486: using_history ();
487: read_history (history_file);
488: }
489: #endif
490:
491: void init_execution_context (void)
492: {
493: register int i;
494:
495: obj_init ();
496:
497: merr_clear ();
498:
499: codptr = code;
500: code[0] = EOL; /* init code_pointer */
501:
502: if ((partition = calloc ((unsigned) (PSIZE + 2), 1)) == NULL) {
503: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate symbol table (error code %d [%s])", errno, strerror (errno));
504: }
505:
506: for (i = 0; i < MAXNO_OF_RBUF; i++) {
507: rbuf_flags[i].standard = standard;
508: }
509:
510: for (i = 0; i < NESTLEVLS; i++) {
511: extr_types[i] = DT_STRING;
512: }
513:
514: symlen = PSIZE;
515: s = &partition[PSIZE] - 256; /* pointer to symlen_offset */
516: argptr = partition; /* pointer to beg of tmp-storage */
517:
518: if ((svntable = calloc ((unsigned) (UDFSVSIZ + 1), 1)) == NULL) {
519: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate user-defined ISV table (error code %d [%s])", errno, strerror (errno));
520: }
521: svnlen = UDFSVSIZ; /* begin of udf_svn_table */
522:
523: if ((buff = calloc ((unsigned) NO_OF_RBUF * (unsigned) PSIZE0, 1)) == NULL) {
524: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate routine buffers (error code %d [%s])", errno, strerror (errno));
525: }
526:
527: if ((newstack = calloc ((unsigned) NSIZE, 1)) == NULL) {
528: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate NEW stack (error code %d [%s])", errno, strerror (errno));
529: }
530:
531: logprintf (FM_LOG_DEBUG, "allocating newptr stack...");
532:
533: newptr = newstack;
534: newlimit = newstack + NSIZE - 1024;
535:
536:
537: if ((namstck = calloc ((unsigned) NESTLEVLS * 13, 1)) == NULL) {
538: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate newptr stack (error code %d [%s])", errno, strerror (errno));
539: }
540:
541: *namstck = EOL;
542: *(namstck + 1) = EOL;
543: namptr = namstck; /* routine name stack pointer */
544:
545: if ((framstck = calloc ((unsigned) NESTLEVLS * 256, 1)) == NULL) {
546: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate DO frame stack stack (error code %d [%s])", errno, strerror (errno));
547: }
548:
549: *framstck = EOL;
550: *(framstck + 1) = EOL;
551: dofrmptr = framstck; /* DO_frame stack pointer */
552:
553: if ((cmdstack = calloc ((unsigned) NESTLEVLS * 256, 1)) == NULL) {
554: logprintf (FM_LOG_FATAL, "init_execution_context: could not allocate command stack (error code %d [%s])", errno, strerror (errno));
555: }
556:
557: cmdptr = cmdstack; /* command stack */
558:
559: rouend = rouins = rouptr = buff;
560: roucur = buff + (NO_OF_RBUF * PSIZE0 + 1);
561: *rouptr = EOL;
562: *(rouptr + 1) = EOL;
563: *(rouptr + 2) = EOL;
564:
565: err_suppl[0] = EOL; /* empty out supplemental error info */
566: }
567:
568: void init_estack (void)
569: {
570: stcpy (merr_stack[0].PLACE, "xecline()\201");
571: }
572:
573: #if defined(HAVE_MWAPI_MOTIF)
574: void init_mwapi (void)
575: {
576: /*
577: if (getenv("DISPLAY") != NULL) {
578: gtk_init (0, NULL);
579: }
580: */
581: /* TODO: init Motif/libXt */
582: }
583: #else
584: void init_mwapi (void)
585: {
586: return;
587: }
588: #endif
589:
590: void init_io (void)
591: {
592: register int i;
593:
594: /* initialize screen */
595: setbuf (stdin, NULL); /* no input buffering */
596: glvnflag.all = 0L;
597: stcpy (buff, "\201");
598: writeHOME (buff);
599: sq_modes[0] = '+';
600: for (i = 0; i <= MAXDEV; ug_buf[i++][0] = EOL); /* init read-buffers */
601:
602: frm_crlf[HOME] = frm_filter;
603:
604: if (hardcopy) zbreakon = ENABLE; /* enable CTRL/B */
605:
606: set_io (MUMPS); /* set i/o parameters */
607:
608: #if !defined(__AMIGA) && !defined(__OS2__)
609: if (ttyname (HOME)) { /* for $IO of HOME */
610: strcpy (dev[HOME], ttyname (HOME));
611: dev[HOME][strlen (dev[HOME])] = EOL;
612: }
613: else {
614: dev[HOME][0] = EOL; /* ...we are in a pipe */
615: }
616: #else
617: #if defined(__AMIGA)
618: strcpy (dev[HOME], "CONSOLE:");
619: #else
620: #if defined(__OS2__)
621: strcpy (dev[HOME], "CON:");
622: #endif
623: #endif
624: #endif
625:
626: /* init function keys */
627: for (i = 0; i < 44; zfunkey[i++][0] = EOL);
628: }
629:
630: void init_random_number (void)
631: {
632:
633: srand (time (NULL));
634:
635: if ((nrandom = time (0L) * getpid ()) < 0) {
636: nrandom = (-nrandom);
637: }
638:
639: }
640:
641: void init_ztrap (void)
642: {
643:
644: if (frm_filter) {
645: ztrap[0][0] = EOL; /* no default ztrap for filters */
646: }
647: else if (startuprou[0] == '^') {
648: stcpy (ztrap[0], startuprou);
649: }
650: else {
651: stcpy (ztrap[0], "^%SYSINIT\201");
652: }
653:
654: /* $ZT to be xecuted on startup */
655:
656: stcpy (ztrap[NESTLEVLS + 1], ztrap[0]); /* DSM V.2 error trapping */
657:
658: }
659:
660: void init_ssvn(void)
661: {
662: ssvn_job_update ();
663: ssvn_display_update ();
664: ssvn_routine_update ();
665: ssvn_library_update ();
666: if (first_process) ssvn_system_update ();
667: }
668:
669: void init_terminal(void)
670: {
671: xpos[HOME] = 80;
672: ypos[HOME] = 24;
673: }
674:
675: void reset_terminal(void)
676: {
677: struct termio tpara;
678:
679: ioctl (0, TCGETA, &tpara);
680:
681: tpara.c_lflag |= (ECHO | ICANON); /* enable echo/no cbreak mode */
682: tpara.c_iflag |= ICRNL; /* cr-lf mapping */
683: tpara.c_oflag |= ONLCR; /* cr-lf mapping */
684: tpara.c_cc[VMIN] = EOT;
685: tpara.c_cc[VTIME] = -1;
686:
687: ioctl (0, TCSETA, &tpara);
688: }
689:
690: void cleanup (void)
691: {
692: char k_buf[256];
693: int ch;
694:
695: /* remove this job's entry from ^$JOB SSVN */
696: snprintf (k_buf, sizeof (k_buf) - 1, "^$JOB\202%d\201", pid);
697: symtab_shm (kill_sym, k_buf, " \201");
698:
699: reset_terminal ();
700:
701: if (tp_level > 0) {
702:
703: if (direct_mode == TRUE) {
704: fprintf (stderr, "UNCOMMITTED TRANSACTIONS EXIST:\n\n");
705: tp_tdump ();
706: set_io (UNIX);
707: fprintf (stderr, "\nWould you like to c)ommit or r)ollback the above transactions and their operations? ($TLEVEL = %d) ", tp_level);
708:
709: for (;;) {
710: ch = fgetc (stdin);
711:
712: if (ch == 'c' || ch == 'C') {
713: while (tp_level > 0) tp_tcommit ();
714:
715: fprintf (stderr, "\n\nTransactions have been committed.\n");
716:
717: break;
718: }
719: else if (ch == 'r' || ch == 'R') {
720: tp_trollback (tp_level);
721:
722: fprintf (stderr, "\n\nTransactions have been rolled back.\n");
723:
724: break;
725: }
726: else {
727: fprintf (stderr, "\n\nInvalid input '%c'. Must choose c)ommit or r)ollback.\n", ch);
728: }
729: }
730: }
731: else {
732: fprintf (stderr, "Uncommitted transactions exist. Rolling back.\n");
733: tp_trollback (tp_level);
734: }
735: }
736:
737: #if defined(HAVE_LIBREADLINE)
738: write_history (history_file);
739: #endif
740:
741: locktab_unlock_all ();
742: job_remove (pid);
743:
744: shm_exit ();
745:
746: if (run_daemon == TRUE) {
747:
748: if (pid_fd != -1) {
749: lockf (pid_fd, F_ULOCK, 0);
750: close (pid_fd);
751: }
752:
753: if (pid_file_path != NULL) {
754: unlink (pid_file_path);
755: }
756:
757: }
758:
759:
760:
761: free (buff); /* free previously allocated space */
762: free (svntable);
763: if (partition) free (partition);
764: if (apartition) free (apartition);
765:
766:
767: free (newstack);
768:
769:
770: if (v22size) free (v22ali);
771:
772: return;
773: } /* end of cleanup */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>