On Friday 02 November 2007 19:59, Marc Blumentritt wrote:
> Hi bb list,
> 
> #!/bin/sh
> # Copyright 2006-2007 Gentoo Foundation
> # Distributed under the terms of the GNU General Public License v2
> 
> # Ensure we are called by init
> echo "PPID = $PPID"
> #[ "$PPID" == "1" ] || exit 0
> 
> I would expect a PPID of 1, bit I get something like 833! But if a check
> with ps, init has PID of 1?! I cannot explain this. I also used sysvinit
> instead of bb init and checked PPID in a similar way and got the same
> result! The only idea I have, where this could come from is, that
> /bin/sh is of course a link to /bin/busybox. Perhaps this breaks
> checking PPID? Or this is some kind of bug? Or is this related with
> running a system in rootfs of initramfs?

I think that your process gets started from a child if init, not
an init itself. Do "ps -A" and send output to the list,
and alsoo look up what process has PID 833.


> 2.) There seems to be a bug in bb grep. I did this on my machine:
> 
> hive ~ # busybox grep -Fow usbfs /proc/filesystems
> Segmentation fault
> hive ~ # busybox grep -Fo usbfs /proc/filesystems
> Segmentation fault
> hive ~ # busybox grep -F usbfs /proc/filesystems
> nodev   usbfs
> hive ~ # busybox grep -o usbfs /proc/filesystems
> usbfs
> hive ~ # busybox grep -w usbfs /proc/filesystems
> nodev   usbfs
> hive ~ # busybox grep -ow usbfs /proc/filesystems
> usbfs
> hive ~ # busybox grep usbfs /proc/filesystems
> nodev   usbfs
> 
> The first two should certainly not result in a Segmentation fault, right?

It's easier to track reports if you have one bug report per mail,
not several unrelated bugs.

Try attached patch.
--
vda
diff -d -urpN busybox.7/findutils/grep.c busybox.8/findutils/grep.c
--- busybox.7/findutils/grep.c	2007-10-20 21:16:24.000000000 +0100
+++ busybox.8/findutils/grep.c	2007-11-04 00:26:52.000000000 +0000
@@ -174,7 +174,7 @@ static int grep_file(FILE *file)
 
 	while ((line = xmalloc_getline(file)) != NULL) {
 		llist_t *pattern_ptr = pattern_head;
-		grep_list_data_t *gl;
+		grep_list_data_t *gl = gl; /* for gcc */
 
 		linenum++;
 		found = 0;
@@ -274,8 +274,15 @@ static int grep_file(FILE *file)
 				print_n_lines_after = lines_after;
 #endif
 				if (option_mask32 & OPT_o) {
-					line[regmatch.rm_eo] = '\0';
-					print_line(line + regmatch.rm_so, linenum, ':');
+					if (FGREP_FLAG) {
+						/* -Fo just prints the pattern
+						 * (unless -v: -Fov doesnt print anything at all) */
+						if (found)
+							print_line(gl->pattern, linenum, ':');
+					} else {
+						line[regmatch.rm_eo] = '\0';
+						print_line(line + regmatch.rm_so, linenum, ':');
+					}
 				} else {
 					print_line(line, linenum, ':');
 				}
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to