4 #if (defined(sun) && ! defined(sparc)) || defined(vax)
10 static char *save_stack_base
;
11 static char *stack_lo_addr
;
12 static char *stack_hi_addr
;
13 static int stack_size
;
15 static int restart_global_flag
;
16 static char *old_file_name
;
17 static char *new_file_name
;
19 char *util_save_sp
; /* set by util_restart_save_state() */
27 for(i
= 0; i
< 256; i
++) {
30 if ((char *) &i
> stack_lo_addr
) {
38 handle_sigquit(int sig
, int code
, struct sigcontext
*scp
)
40 if (util_restart_save_state()) {
41 /* we are restarting ! -- return from signal */
44 /* copy stack to user data space */
45 stack_lo_addr
= util_save_sp
;
46 stack_size
= stack_hi_addr
- stack_lo_addr
+ 1;
47 save_stack_base
= sbrk(stack_size
);
48 (void) memcpy(save_stack_base
, stack_lo_addr
, stack_size
);
50 /* write a new executable */
51 (void) fprintf(stderr
, "Writing executable %s ...\n", new_file_name
);
52 (void) util_save_image(old_file_name
, new_file_name
);
54 /* terminate if signal was a QUIT */
65 (void) fprintf(stderr
, "Continuing execution ...\n");
67 /* create the stack */
71 asm("movl _util_save_sp,sp");
74 asm("movl _util_save_sp,sp");
77 /* copy the stack back from user space */
78 (void) memcpy(stack_lo_addr
, save_stack_base
, stack_size
);
80 /* remove the sbrk for the stack */
81 if (sbrk(-stack_size
) < 0) {
85 util_restart_restore_state(); /* jump back into handle_sigquit() */
89 util_restart(char const *old
, char const *neW
, int interval
)
91 struct itimerval itimer
;
95 stack_hi_addr
= (char *) 0x7fffe3ff; /* ultrix */
97 stack_hi_addr
= (char *) 0x7fffebff; /* bsd 4.3 */
101 stack_hi_addr
= (char *) 0x0effffff; /* Sun OS 3.2, 3.4 */
107 (void) signal(SIGQUIT
, handle_sigquit
);
110 (void) signal(SIGVTALRM
, handle_sigquit
);
111 itimer
.it_interval
.tv_sec
= interval
;
112 itimer
.it_interval
.tv_usec
= 0;
113 itimer
.it_value
.tv_sec
= interval
;
114 itimer
.it_value
.tv_usec
= 0;
115 if (setitimer(ITIMER_VIRTUAL
, &itimer
, (struct itimerval
*) 0) < 0) {
121 if (restart_global_flag
) {
124 restart_global_flag
= 1;
131 util_restart(char const *old
, char const *neW
, int interval
)
133 (void) fprintf(stderr
,
134 "util_restart: not supported on your operating system/hardware\n");