From owner-freebsd-questions@FreeBSD.ORG Mon Jul 3 08:27:05 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E2C2C16A412 for ; Mon, 3 Jul 2006 08:27:05 +0000 (UTC) (envelope-from nospam@mgedv.net) Received: from mail.mgedv.net (mail.mgedv.net [81.223.168.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id 689BD43D48 for ; Mon, 3 Jul 2006 08:27:04 +0000 (GMT) (envelope-from nospam@mgedv.net) Received: from metis (sslint.my.loop [1.1.1.1]) by mail.my.loop (mgedv) with ESMTP id 15B19457A5 for ; Mon, 3 Jul 2006 10:27:03 +0200 (CEST) From: "no@spam@mgedv.net" To: Date: Mon, 3 Jul 2006 10:27:06 +0200 Message-ID: <006701c69e7a$7898db00$01010101@avalon.lan> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcaeeneZn1OUzAY9SWqqKs/u8dXD1Q== Subject: shell scripting: help appreciated X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jul 2006 08:27:06 -0000 short and weird problem description (from my point of view): /bin/sh stops working correctly with a content-controlled do-loop. the shell-script layout is as follows: (it's not that trivial, just to show the meaning) --------------------------------------------------------------- /test/foo.conf (originally ~60 lines): test1 testval1 optional_testval1 test2 testval2 optional_testval2 /test/foo.sh (this is the original loop code): cat "$g_dir_etc/compile.lst"|\ sed -e 's-^ *--g'|\ sed -e 's-^ *--g'|\ grep -v '^#'|\ sed -e 's-#.*$--g'|\ grep -v '^$'|\ while read gh_name gh_src gh_srcdir do /bin/sh -c subprogram.sh $h_val1 $h_val2 $h_opt1; done; /test/foo_sub.sh: --------------------------------------------------------------- if i change the line /bin/sh -c subprogram.sh $h_val1 $h_val2 $h_opt1; to echo /bin/sh -c subprogram.sh $h_val1 $h_val2 $h_opt1; the program loops for all records in the foo.conf correctly. if i remove the "echo" keyword, the sub-script get's executed, but the shell terminates as if there were lesser records in the foo.conf file! i scripted as many debug messages as possible, for every loop they get executed and there are no errors/etc... happening. and interestingly, the execution stops always on the same record! if i comment out some records of my foo.conf, the sub-shell gets executed for more records. it seems like something with a buffer or somewhat, but i'm not a debugger/c-guru, so i don't know where to start here... maybe i'm using a wrong technique for looping? some facts: conf-file is readable and doesn't change during execution the scripts also don't change during exec we're running on 6.1-RELEASE with 2GB RAM and a XEON 2.8 no errors/warnings during exec-time from kernel or daemons fs is fine, fsck is happy! everything runs /bin/sh. the whole scripts runs currently ~45min. if i change the subshell to an empty script with just "hi i'm here" and "exit 1;" the loop works for all records in the .conf file. any ideas, what the hell is going on here?