"Ben Dibell" <thinkingrod...@gmail.com> wrote: > === "Ben Dibell" <thinkingrod...@gmail.com> wrote: > === > ===> Hi, I've tried other resources, even reading the > source for init, but I > ===> can't seem to locate the magic that > makes /sbin/init the approved init. > ===> I'm porting my init > system Epoch to BSD for personal reasons, and I'd > ===> like > ===> it to work under OpenBSD, which I've been enjoying as of late. I > come > ===> from > ===> the linux world where init=/bin/sh is > perfectly valid, so some aspects > ===> are > ===> probably > simpler in Linux. I am hoping there is a concise and clean > ===> > explanation as to how to write/port an init system to BSD. Is it signal > ===> trickery? A checksum burned into the kernel? I'm lost. I'm given > "init > ===> has > ===> died, signal 0 exit 0" or > something nearly identical to this. There are > ===> no > ===> > further useful debug messages and my keyboard becomes unresponsive on > ===> the > ===> debugging prompt or the kernel locks up or > something, so I can't do more > ===> there. > ===> > ===> Thanks for your time. > ===> > ===> -Ben > === > > === The kernel doesn't support any command line syntax like that but > I don't > === know why it wouldn't let you use any static binary. You > should read > === kernel sources too if you're serious about this. > === > === But I don't see your point. Obviously you can do what > makes you happy on > === your systems but have you thought about what > OpenBSD init does vs. what > === your init does? init (among other > things) exists to run getty and start > === /etc/rc. You mention status > in a further message. You probably want to > === keep logs and manage > daemon state like the other newfangled init > === systems. You're going > to have to rewrite both init and the rc system. > === And you won't get > any support for such a system. > === > === And if you want to > monitor daemons you'll be better off monitoring the > === service the > daemons are supposed to provide. It doesn't matter if httpd > === > hasn't exited yet if you can't connect to it. > === > === - Martin > Brandenburg > === > > Well, I'm not asking for anyone to > support me once I get it going. Right now I just want to get stdout/stderr > working and perhaps I can get it running in a crippled but visibly > semi-functional state so I can continue my work porting.
You've heard that fds 0, 1, and 2 are guaranteed to be open to your process when it starts. You are trying to make use of them, but you are writing the first userspace code to run on a system. So you must ask when they get open. If you would actually read init.c, you will see a function like setctty which must be called to perform this work. I recommend you learn what login_tty does as well. If you open /dev/console you can write things to the console. Otherwise write(1, ...) fails. (What's more, I have bothered to test this, so I know I'm telling the truth.) You are expected to read code and figure these things out yourself. You are unlikely to get someone to do this for you again on this list. - Martin Brandenburg