[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug report. MiNT 1.07; more init patches...
Juergen Lock writes:
> > Machine:- TT030, 8MB RAM (4+4), standard TT Hard drive + ICD adaptor and
> > 85MB seagate drive on ACSI bus.
> >
> > (1) When opening serial ports modem2, serial1 and serial2, modem1 is opened.
>
> hmm haven't seen that one... actually my uucico (taylor 1.03) just
> received this mail over modem2, without any problems. this is MiNT 1.09...
i forgot to say this is a megaSTe, maybe the bug is >68000 specific...
anyway, i now have halt working again (searches init now) and made init
sync minixfs and don't wait for TSRs when killed. and syslogd now forks
itself into background to reduce fragmentation a bit.
diff -ru .b/halt/Makefile ./halt/Makefile
--- .b/halt/Makefile Thu Aug 5 21:53:48 1993
+++ ./halt/Makefile Wed Sep 1 17:15:00 1993
@@ -2,7 +2,7 @@
SHELL = /bin/sh
-CPPFLAGS = -I../include
+CPPFLAGS = -I../include -DMINT
EXTRALIBS = ../lib/libusers.a ../syslog/libsyslog.a
diff -ru .b/halt/halt.c ./halt/halt.c
--- .b/halt/halt.c Wed Sep 1 16:30:04 1993
+++ ./halt/halt.c Thu Sep 2 14:45:36 1993
@@ -2,10 +2,66 @@
#include <signal.h>
#include <sys/syslog.h>
+#ifdef MINT
+#include <ioctl.h>
+#include <sys/dir.h>
+
+typedef unsigned long ulong;
+
+typedef struct _context {
+ long regs[15]; /* registers d0-d7, a0-a6 */
+ long usp; /* user stack pointer (a7) */
+ short sr; /* status register */
+ long pc; /* program counter */
+ long ssp; /* supervisor stack pointer */
+ long term_vec; /* GEMDOS terminate vector (0x102) */
+
+/* these fields were added in MiNT 0.9 */
+ char fstate[216]; /* FPU internal state */
+ char fregs[12*8]; /* registers fp0-fp7 */
+ long fctrl[3]; /* FPCR/FPSR/FPIAR */
+ short sfmt; /* stack frame format identifier */
+ long iar; /* instruction address */
+ short internal[4]; /* four words of internal info */
+} CONTEXT;
+
+struct pinfo {
+ long magic;
+ char *base;
+ short pid, ppid, pgrp;
+ short ruid, rgid;
+ short euid, egid;
+ short memflags;
+ short pri;
+ short wait_q;
+ long wait_cond;
+ /* (all times are in milliseconds) */
+ ulong systime; /* time spent in kernel */
+ ulong usrtime; /* time spent out of kernel */
+ ulong chldstime; /* children's kernel time */
+ ulong chldutime; /* children's user time */
+
+ ulong maxmem; /* max. amount of memory to use */
+ ulong maxdata; /* max. data region for process */
+ ulong maxcore; /* max. core memory for process */
+ ulong maxcpu; /* max. cpu time to use */
+
+ short domain; /* process domain (TOS or MiNT) */
+ short curpri; /* current priority (nice) */
+};
+#endif
+
main(argc, argv)
int argc;
char *argv[];
{
+#ifdef MINT
+ int pid, initpid;
+ DIR *procdir;
+ struct direct *entry;
+ char *pointer;
+#endif
+
if (getuid() != 0)
{
printf("You need to be root to run halt.\n");
@@ -19,8 +75,52 @@
syslog(LOG_NOTICE, "halted by root");
closelog();
+#ifdef MINT
+ if ((procdir = opendir("u:/proc")) == NULL)
+ {
+ perror("opendir: u:/proc");
+ }
+ else
+ {
+ /* look for process called init with ppid 0
+ */
+ while ((entry = readdir(procdir)) != NULL)
+ {
+ char statf[0x80] = "u:/proc/";
+ int fd;
+
+ entry->d_name[entry->d_namlen] = '\0';
+ pointer = strchr(entry->d_name, '.');
+ sscanf(++pointer, "%3d", &pid);
+ strcpy (statf+sizeof "u:/proc", entry->d_name);
+ if (!strncmp
+ (entry->d_name, "init.", pointer-1-entry->d_name) &&
+ (fd = open (statf, 0)) >=0) {
+ long place;
+ long ctxtsize;
+ struct pinfo proc;
+
+ ioctl(fd, PPROCADDR, &place);
+ if (ioctl(fd, PCTXTSIZE, &ctxtsize) < 0) {
+ lseek(fd, place+4+2*sizeof(CONTEXT), 0);
+ } else
+ lseek(fd, place, 0);
+ read(fd, &proc, sizeof(proc));
+ if (proc.pid == pid && proc.ppid <= 0) {
+ initpid = pid;
+ break;
+ }
+ }
+ }
+ closedir(procdir);
+ }
+
+ if (kill(initpid, SIGTERM) == -1)
+ perror("kill");
+#else
if (kill(1, SIGTERM) == -1)
perror("kill");
+#endif
sleep(1);
}
diff -ru .b/init/init.c ./init/init.c
--- .b/init/init.c Thu Sep 2 14:52:40 1993
+++ ./init/init.c Wed Sep 1 14:54:54 1993
@@ -46,6 +46,7 @@
#ifdef MINT
#include <ioctl.h>
#include <sys/dir.h>
+#include <sys/stat.h>
#include <mintbind.h>
extern char *strchr();
@@ -59,6 +60,7 @@
static int shutdown = 0;
static int exit_anyway = 0;
static int times_up = 0;
+static int updatepid = 0;
int flags;
@@ -364,6 +366,14 @@
printf("Syncing file systems...");
fflush(stdout);
+#ifdef MINT
+ /* sync minixfs... */
+ if (updatepid) {
+ kill (updatepid, SIGALRM);
+ sleep (5);
+ }
+#endif
+
#ifdef SYNC_FILESYS
sync();
sync();
@@ -417,10 +427,21 @@
{
while ((entry = readdir(procdir)) != NULL)
{
+ char statf[0x80] = "u:/proc/";
+ struct stat st;
+
entry->d_name[entry->d_namlen] = '\0';
pointer = strchr(entry->d_name, '.');
sscanf(++pointer, "%3d", &pid);
- if ((pid != getpid()) && (pid != 0))
+ if (!updatepid && pid < getpid() && !strncmp
+ (entry->d_name, "update.", pointer-1-entry->d_name))
+ updatepid = pid;
+
+ /* don't wait() for update or TSRs... -nox */
+ strcpy (statf+sizeof "u:/proc", entry->d_name);
+ if ((pid != getpid()) && (pid != 0) &&
+ (pid != updatepid) && !stat (statf, &st) &&
+ !(st.st_attr & FA_HIDDEN))
{
num_procs++;
switch (first_time)
diff -ru .b/syslog/syslogd.c ./syslog/syslogd.c
--- .b/syslog/syslogd.c Tue Aug 10 00:07:46 1993
+++ ./syslog/syslogd.c Thu Sep 2 14:39:28 1993
@@ -134,6 +134,7 @@
char ctty[] = CTTY;
#ifdef atarist
+#include <setjmp.h>
#include <osbind.h>
char *PipeName = "\\pipe\\log";
#endif
@@ -281,6 +282,22 @@
extern char *sys_errlist[];
extern char *ctime(), *index(), *calloc();
+#ifdef atarist
+/* on MiNT fork and vfork both block until the child does either exec or
+ dies. only tfork doesn't block but it works like a subroutine call... */
+static jmp_buf tforkj;
+
+static int in_tfork(arg)
+int arg;
+{
+ /* wait for parent to die before we can longjmp back */
+ while (getppid () > 1)
+ sleep (1);
+ longjmp (tforkj, 1);
+ /*NOTREACHED*/
+}
+#endif
+
main(argc, argv)
int argc;
char **argv;
@@ -327,6 +344,11 @@
#ifndef atarist
if (fork())
exit(0);
+#else
+ /* hack until MiNT gets a real nonblocking fork... one day :)
+ */
+ if (!setjmp(tforkj) && tfork (in_tfork, 0) >= 0)
+ _exit (0);
#endif
#ifdef SYSV
sleep(5); /* Why wont it work without this?! -- ASP */
--
J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
...ohne Gewehr
PGP public key fingerprint = 8A 18 58 54 03 7B FC 12 1F 8B 63 C7 19 27 CF DA