On 06.07.2012 15:03, Laurent Bercot wrote: >> As I stated in my initial email, when running awk from a subshell >> it works. I know PID=1 is special, and for one, it can't be straced >> or debugged. > > Actually, on some Linux versions (I'm not certain which ones though, > but it should work on modern kernels), process 1 *can* be straced: > somehow get a shell running and do "strace -p 1". If you're not afraid > of dirty hacks, you could even run that from your /init, if everything > is properly mounted: > ( strace -p 1 </dev/null >/dev/null 2>/tmp/strace-file ) & > or even replace /tmp/strace-file with /dev/tty for a live performance.
I tried this right away, but failed: strace does not show anything at all in that case, even if the process 1 actually does something. No, I'm not afraid at all, since it is trivial to experiment in a virtual machine. And I don't think strace will do anything interesting here: I looked at what happens when busybox ash spawns awk in a regular case, there, it just forks (with a pipe open) and does one or two read/writes -- it is ofcourse not enough information to understand what's going on. It may help a bit ofcourse, if I'll add a few debug printfs here and there. Ideally it'd be nice to get a coredump, but for some reason the process being fork'ed in this context isn't dumpable. >> And finally, it isn't a solution to run it from a subshell, >> since running awk from within /init in initramfs is a valid usage >> case. > > But are you really running awk as process 1 ? > I doubt your /init script is *executing* awk. If it was, then after > performing its work, awk would die, and your kernel would panic. > I suspect that instead, your /init script looks like > > #!/bin/sh > ... > awk something > ... > exec chroot foobar /sbin/init > > in which case you are *not* running awk as process 1: your shell is > forking first, then executing awk as a child. The question then becomes, > why is there a problem when awk is run directly as process 1's child. Well. My $subject is inaccurate. I meant to say when awk is spawned from pid=1 as NOEXEC applet. The code like rootfs=`awk '$2=="/"{print $1}` or anything of this theme. This works: rootfs=`/bin/awk '$2=="/"{print $1}` rootfs=`busybox awk '$2=="/"{print $1}` and this rootfs=`awk '$2=="/"{print $1}` segfaults, just like a bare 'awk' call: awk (in normal case it produces an error message about invalid usage). Thank you! /mjt _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox