/[cmucl]/src/tools/hpux-startup.c
ViewVC logotype

Contents of /src/tools/hpux-startup.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Fri Feb 17 12:07:49 1995 UTC (19 years, 2 months ago) by wlott
Branch: MAIN
CVS Tags: sparc-tramp-assem-base, double-double-array-base, post-merge-intl-branch, release-19b-pre1, release-19b-pre2, merged-unicode-utf16-extfmt-2009-06-11, double-double-init-sparc-2, unicode-utf16-extfmt-2009-03-27, double-double-base, snapshot-2007-09, snapshot-2007-08, snapshot-2008-08, snapshot-2008-09, ppc_gencgc_snap_2006-01-06, sse2-packed-2008-11-12, snapshot-2008-05, snapshot-2008-06, snapshot-2008-07, snapshot-2007-05, snapshot-2008-01, snapshot-2008-02, snapshot-2008-03, intl-branch-working-2010-02-19-1000, snapshot-2006-11, snapshot-2006-10, double-double-init-sparc, snapshot-2006-12, unicode-string-buffer-impl-base, sse2-base, release-20b-pre1, release-20b-pre2, unicode-string-buffer-base, RELEASE_18d, sse2-packed-base, sparc-tramp-assem-2010-07-19, amd64-dd-start, snapshot-2003-10, snapshot-2004-10, release-18e-base, release-19f-pre1, snapshot-2008-12, snapshot-2008-11, intl-2-branch-base, snapshot-2004-08, snapshot-2004-09, remove_negative_zero_not_zero, snapshot-2007-01, snapshot-2007-02, snapshot-2004-05, snapshot-2004-06, snapshot-2004-07, release-19e, release-19d, GIT-CONVERSION, double-double-init-ppc, release-19c, dynamic-extent-base, unicode-utf16-sync-2008-12, LINKAGE_TABLE, release-19c-base, cross-sol-x86-merged, label-2009-03-16, release-19f-base, PRE_LINKAGE_TABLE, merge-sse2-packed, mod-arith-base, sparc_gencgc_merge, merge-with-19f, snapshot-2004-12, snapshot-2004-11, intl-branch-working-2010-02-11-1000, RELEASE_18a, RELEASE_18b, RELEASE_18c, unicode-snapshot-2009-05, unicode-snapshot-2009-06, amd64-merge-start, ppc_gencgc_snap_2005-12-17, double-double-init-%make-sparc, unicode-utf16-sync-2008-07, release-18e-pre2, unicode-utf16-sync-2008-09, unicode-utf16-extfmts-sync-2008-12, prm-before-macosx-merge-tag, cold-pcl-base, RELEASE_20b, snapshot-2008-04, snapshot-2003-11, snapshot-2005-07, unicode-utf16-sync-label-2009-03-16, RELEASE_19f, snapshot-2007-03, release-20a-base, cross-sol-x86-base, unicode-utf16-char-support-2009-03-26, unicode-utf16-char-support-2009-03-25, release-19a-base, unicode-utf16-extfmts-pre-sync-2008-11, snapshot-2008-10, sparc_gencgc, snapshot-2007-04, snapshot-2010-12, snapshot-2010-11, unicode-utf16-sync-2008-11, snapshot-2007-07, snapshot-2011-09, snapshot-2011-06, snapshot-2011-07, snapshot-2011-04, snapshot-2007-06, snapshot-2011-02, snapshot-2011-03, snapshot-2011-01, snapshot-2003-12, release-19a-pre1, release-19a-pre3, release-19a-pre2, pre-merge-intl-branch, release-19a, UNICODE-BASE, double-double-array-checkpoint, double-double-reader-checkpoint-1, release-19d-base, release-19e-pre1, double-double-irrat-end, release-19e-pre2, snapshot-2010-05, snapshot-2010-04, snapshot-2010-07, snapshot-2010-06, snapshot-2010-01, snapshot-2010-03, snapshot-2010-02, release-19d-pre2, release-19d-pre1, snapshot-2010-08, release-18e, double-double-init-checkpoint-1, double-double-reader-base, label-2009-03-25, snapshot-2005-03, release-19b-base, cross-sol-x86-2010-12-20, double-double-init-x86, sse2-checkpoint-2008-10-01, intl-branch-2010-03-18-1300, snapshot-2005-11, double-double-sparc-checkpoint-1, snapshot-2004-04, sse2-merge-with-2008-11, sse2-merge-with-2008-10, snapshot-2005-10, RELEASE_20a, snapshot-2005-12, release-20a-pre1, snapshot-2005-01, snapshot-2009-11, snapshot-2009-12, unicode-utf16-extfmt-2009-06-11, portable-clx-import-2009-06-16, unicode-utf16-string-support, release-19c-pre1, cross-sparc-branch-base, release-19e-base, intl-branch-base, double-double-irrat-start, snapshot-2005-06, snapshot-2005-05, snapshot-2005-04, ppc_gencgc_snap_2005-05-14, snapshot-2005-02, unicode-utf16-base, portable-clx-base, snapshot-2005-09, snapshot-2005-08, lisp-executable-base, snapshot-2009-08, snapshot-2007-12, snapshot-2007-10, snapshot-2007-11, snapshot-2009-02, snapshot-2009-01, snapshot-2009-07, snapshot-2009-05, snapshot-2009-04, snapshot-2006-02, snapshot-2006-03, release-18e-pre1, snapshot-2006-01, snapshot-2006-06, snapshot-2006-07, snapshot-2006-04, snapshot-2006-05, pre-telent-clx, snapshot-2006-08, snapshot-2006-09, HEAD
Branch point for: release-19b-branch, double-double-reader-branch, double-double-array-branch, mod-arith-branch, RELEASE-19F-BRANCH, portable-clx-branch, sparc_gencgc_branch, cross-sparc-branch, RELEASE-20B-BRANCH, RELENG_18, unicode-string-buffer-branch, sparc-tramp-assem-branch, dynamic-extent, UNICODE-BRANCH, release-19d-branch, ppc_gencgc_branch, sse2-packed-branch, lisp-executable, RELEASE-20A-BRANCH, amd64-dd-branch, double-double-branch, unicode-string-buffer-impl-branch, intl-branch, release-18e-branch, cold-pcl, unicode-utf16-branch, cross-sol-x86-branch, release-19e-branch, sse2-branch, release-19a-branch, release-19c-branch, intl-2-branch, unicode-utf16-extfmt-branch
Changes since 1.3: +3 -3 lines
File MIME type: text/plain
Look for cmucl.orig instead of lisp.orig
1 /*
2 * $Header: /tiger/var/lib/cvsroots/cmucl/src/tools/hpux-startup.c,v 1.4 1995/02/17 12:07:49 wlott Rel $
3 *
4 * This file copies the lisp startup code, forks a process that will delete
5 * the copy when the parent exits, and then exec's the copy of the lisp
6 * startup code with the same arguments. This is needed because of a bug in
7 * hpux.
8 */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <sys/file.h>
15
16 typedef int boolean;
17 #define TRUE 1
18 #define FALSE 0
19
20 static char *find_lisp_orig(void)
21 {
22 char *library = getenv("CMUCLLIB");
23 char *src, *dst;
24 static char buffer[1024];
25 boolean found;
26 struct stat statbuf;
27
28 if (library == NULL)
29 library = "/usr/local/lib/cmucl/lib";
30
31 src = library;
32 found = FALSE;
33 do {
34 dst = buffer;
35 while (*src != '\0' && *src != ':')
36 *dst++ = *src++;
37 strcpy(dst, "/cmucl.orig");
38 if (stat(buffer, &statbuf) != -1)
39 if ((statbuf.st_mode & S_IFMT) == S_IFREG) {
40 found = TRUE;
41 break;
42 }
43 } while (*src++ != '\0');
44
45 if (!found) {
46 fprintf(stderr, "Could not find cmucl.orig. Try setting CMUCLLIB.\n");
47 exit(1);
48 }
49
50 return buffer;
51 }
52
53 static char *make_copy(char *source)
54 {
55 static char name[1024];
56 int infd, outfd;
57 int incount, outcount;
58 char buffer[8*1024];
59 char *ptr;
60
61 infd = open(source, O_RDONLY, 0);
62 if (infd < 0) {
63 perror(source);
64 exit(1);
65 }
66
67 sprintf(name, "/tmp/lisp.copy.XXXXXX");
68 outfd = mkstemp(name);
69 if (outfd < 0) {
70 sprintf(buffer, "open(%s)", name);
71 perror(buffer);
72 exit(1);
73 }
74
75 while ((incount = read(infd, buffer, sizeof(buffer))) > 0) {
76 ptr = buffer;
77 while ((outcount = write(outfd, ptr, incount)) != incount) {
78 if (outcount < 0) {
79 sprintf(buffer, "write(%s)", name);
80 perror(buffer);
81 exit(1);
82 }
83 incount -= outcount;
84 ptr += outcount;
85 }
86 }
87
88 if (incount < 0) {
89 sprintf(buffer, "read(%s)", source);
90 perror(buffer);
91 exit(1);
92 }
93
94 if (close(infd) < 0) {
95 sprintf(buffer, "close(%s)", source);
96 perror(buffer);
97 exit(1);
98 }
99
100 if (close(outfd) < 0) {
101 sprintf(buffer, "close(%s)", name);
102 perror(buffer);
103 exit(1);
104 }
105
106 if (chmod(name, 0700) < 0) {
107 sprintf(buffer, "chmod(%s)", name);
108 perror(buffer);
109 exit(1);
110 }
111
112 return name;
113 }
114
115 static void spawn_nuker(char *file)
116 {
117 int pid = fork();
118
119 if (pid < 0) {
120 perror("fork");
121 exit(1);
122 }
123
124 if (pid > 0)
125 /* The parent process. */
126 return;
127
128 if (setpgrp(0, 0) < 0) {
129 perror("setpgrp(0,0)");
130 exit(1);
131 }
132
133 while (getppid() != 1)
134 sleep(5);
135
136 unlink(file);
137
138 exit(0);
139 }
140
141 main(int argc, char *argv[])
142 {
143 char *file;
144
145 file = make_copy(find_lisp_orig());
146
147 spawn_nuker(file);
148
149 if (execv(file, argv) < 0) {
150 char buffer[256];
151 sprintf(buffer, "execv(%s)", file);
152 perror(buffer);
153 exit(1);
154 }
155 }

  ViewVC Help
Powered by ViewVC 1.1.5