Cleanup of halt.c.
write_log();
- if (fast) {
- /* But not too fast... */
- signal(SIGTERM, SIG_IGN);
- kill(1, SIGTERM);
- printf("Sending SIGTERM to all processes ...\n");
- kill(-1, SIGTERM);
- sleep(1);
- } else {
- /* Run the shutdown scripts. */
- signal(SIGHUP, SIG_IGN);
- signal(SIGTERM, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ /* Skip this part for fast shut down. */
+ if (! fast) {
+ /* Run the shutdown scripts. */
switch ((pid = fork())) {
case -1:
fprintf(stderr, "%s: can't fork(): %s\n", prog, strerror(errno));
default:
while (waitpid(pid, NULL, 0) != pid) {}
}
+ }
- /* Tell init to stop spawning getty's. */
- kill(1, SIGTERM);
+ /* Tell init to stop spawning getty's. */
+ kill(1, SIGTERM);
- /* Give everybody a chance to die peacefully. */
- printf("Sending SIGTERM to all processes ...\n");
- kill(-1, SIGTERM);
- sleep(2);
- }
+ /* Give everybody a chance to die peacefully. */
+ printf("Sending SIGTERM to all processes ...\n");
+ kill(-1, SIGTERM);
+ sleep(2);
sync();
$(LIBRARY)(_svrctl.o) \
$(LIBRARY)(_getsysinfo.o) \
$(LIBRARY)(_getprocnr.o) \
+ $(LIBRARY)(_getpprocnr.o) \
+ $(LIBRARY)(_getnprocnr.o) \
+ $(LIBRARY)(_getnpid.o) \
$(LIBRARY)(_devctl.o) \
$(LIBRARY)(_findproc.o) \
$(LIBRARY)(asynchio.o) \
$(LIBRARY)(_devctl.o): _devctl.c
$(CC1) _devctl.c
+$(LIBRARY)(_getnpid.o): _getnpid.c
+ $(CC1) _getnpid.c
+
$(LIBRARY)(_getprocnr.o): _getprocnr.c
$(CC1) _getprocnr.c
+$(LIBRARY)(_getpprocnr.o): _getpprocnr.c
+ $(CC1) _getpprocnr.c
+
+$(LIBRARY)(_getnprocnr.o): _getnprocnr.c
+ $(CC1) _getnprocnr.c
+
$(LIBRARY)(_findproc.o): _findproc.c
$(CC1) _findproc.c
--- /dev/null
+#include <lib.h>
+#define getnpid _getnpid
+#include <unistd.h>
+
+PUBLIC pid_t getnpid(int proc_nr)
+{
+ message m;
+ m.m1_i1 = proc_nr; /* search pid for this process */
+ if (_syscall(MM, GETPID, &m) < 0) return ( (pid_t) -1);
+ return( (pid_t) m.m2_i2); /* return search result */
+}
--- /dev/null
+#include <lib.h>
+#define getnprocnr _getnprocnr
+#include <unistd.h>
+
+
+PUBLIC int getnprocnr(pid_t pid)
+{
+ message m;
+ m.m1_i1 = pid; /* pass pid >=0 to search for */
+ m.m1_i2 = 0; /* don't pass name to search for */
+ if (_syscall(PM_PROC_NR, GETPROCNR, &m) < 0) return(-1);
+ return(m.m1_i1); /* return search result */
+}
+
--- /dev/null
+#include <lib.h>
+#define getpprocnr _getpprocnr
+#include <unistd.h>
+
+
+PUBLIC int getpprocnr()
+{
+ message m;
+ m.m1_i1 = -1; /* don't pass pid to search for */
+ m.m1_i2 = 0; /* don't pass name to search for */
+ if (_syscall(PM_PROC_NR, GETPROCNR, &m) < 0) return(-1);
+ return(m.m1_i2); /* return parent process number */
+}
+
PUBLIC int getprocnr()
{
message m;
- m.m1_i1 = -1; /* get own process number */
- m.m1_i2 = 0; /* get own process number */
- if (_syscall(MM, GETPROCNR, &m) < 0) return(-1);
- return(m.m1_i1);
+ m.m1_i1 = -1; /* don't pass pid to search for */
+ m.m1_i2 = 0; /* don't pass name to search for */
+ if (_syscall(PM_PROC_NR, GETPROCNR, &m) < 0) return(-1);
+ return(m.m1_i1); /* return own process number */
}
$(LIBRARY)(getgroups.o) \
$(LIBRARY)(getpgrp.o) \
$(LIBRARY)(getpid.o) \
+ $(LIBRARY)(getnpid.o) \
$(LIBRARY)(getppid.o) \
$(LIBRARY)(getuid.o) \
$(LIBRARY)(getprocnr.o) \
+ $(LIBRARY)(getpprocnr.o) \
+ $(LIBRARY)(getnprocnr.o) \
$(LIBRARY)(getsysinfo.o) \
$(LIBRARY)(findproc.o) \
$(LIBRARY)(ioctl.o) \
$(LIBRARY)(getpid.o): getpid.s
$(CC1) getpid.s
+$(LIBRARY)(getnpid.o): getnpid.s
+ $(CC1) getnpid.s
+
$(LIBRARY)(getppid.o): getppid.s
$(CC1) getppid.s
$(LIBRARY)(getprocnr.o): getprocnr.s
$(CC1) getprocnr.s
+$(LIBRARY)(getnprocnr.o): getnprocnr.s
+ $(CC1) getnprocnr.s
+
+$(LIBRARY)(getpprocnr.o): getpprocnr.s
+ $(CC1) getpprocnr.s
+
$(LIBRARY)(findproc.o): findproc.s
$(CC1) findproc.s
--- /dev/null
+.sect .text
+.extern __getnpid
+.define _getnpid
+.align 2
+
+_getnpid:
+ jmp __getnpid
--- /dev/null
+.sect .text
+.extern __getnprocnr
+.define _getnprocnr
+.align 2
+
+_getnprocnr:
+ jmp __getnprocnr
--- /dev/null
+.sect .text
+.extern __getpprocnr
+.define _getpprocnr
+.align 2
+
+_getpprocnr:
+ jmp __getpprocnr