From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 19 11:30:04 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1AE3B16A420 for ; Sun, 19 Feb 2006 11:30:04 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: from pne-smtpout2-sn1.fre.skanova.net (pne-smtpout2-sn1.fre.skanova.net [81.228.11.159]) by mx1.FreeBSD.org (Postfix) with ESMTP id 652FD43D46 for ; Sun, 19 Feb 2006 11:30:02 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: from falcon.midgard.homeip.net (83.253.29.241) by pne-smtpout2-sn1.fre.skanova.net (7.2.070) id 43EC2A6A002199B3 for hackers@freebsd.org; Sun, 19 Feb 2006 12:30:01 +0100 Received: (qmail 12712 invoked by uid 1001); 19 Feb 2006 12:30:01 +0100 Date: Sun, 19 Feb 2006 12:30:01 +0100 From: Erik Trulsson To: Divacky Roman Message-ID: <20060219113001.GA12683@falcon.midgard.homeip.net> Mail-Followup-To: Divacky Roman , hackers@freebsd.org References: <20060218171718.GA73133@stud.fit.vutbr.cz> <20060218172152.GB11874@britannica.bec.de> <20060218173908.GA73913@stud.fit.vutbr.cz> <20060218214329.GF69162@funkthat.com> <20060219105438.GA12265@stud.fit.vutbr.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060219105438.GA12265@stud.fit.vutbr.cz> User-Agent: Mutt/1.5.11 Cc: hackers@freebsd.org Subject: Re: different behaviour on fbsd and linux X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2006 11:30:04 -0000 On Sun, Feb 19, 2006 at 11:54:38AM +0100, Divacky Roman wrote: > On Sat, Feb 18, 2006 at 01:43:30PM -0800, John-Mark Gurney wrote: > > Divacky Roman wrote this message on Sat, Feb 18, 2006 at 18:39 +0100: > > > On Sat, Feb 18, 2006 at 06:21:52PM +0100, joerg@britannica.bec.de wrote: > > > > On Sat, Feb 18, 2006 at 06:17:18PM +0100, Divacky Roman wrote: > > > > > execl("/bin/ls", NULL); > > > > > > > > This is wrong. You must specify arg0 != NULL (POSIX says so) and you > > > > must NULL-terminate the *following* list. > > > > > > > > E.g.: > > > > execl("/bin/ls", "/bin/ls", NULL); > > > > is what you want to do. > > > > > > > > > ah.. thnx.. the man page should be updated with "he > > > first argument, by convention, should point to the file name associated > > > with the file being executed." > > > > > > s/should/must then > > > > Nope.. it need not be the same.. in cases like this: > > execl("/usr/bin/gzip", "gunzip", NULL); > > > > will give you gunzip behavior because the gzip binary looks at argv[0] > > and changes it's behavior based upon what it finds.. look at crunchgen > > for the ability to combine different programs into one binary... > > ok.. but I'd appreciate info that it cannot be NULL ;( It is in the manpage if you read carefully. execl(8) says: [...] int execl(const char *path, const char *arg, ... /*, (char *)0 */); [...] The const char *arg and subsequent ellipses in the execl(), execlp(), and execle() functions can be thought of as arg0, arg1, ..., argn. Together they describe a list of one or more pointers to null-terminated strings that represent the argument list available to the executed program. The first argument, by convention, should point to the file name associated with the file being executed. The list of arguments must be terminated by a NULL pointer. [...] Note that it says "one or more pointers to null-terminated strings". NULL is not a pointer to a null-terminated string, which means that you must have at least one non-NULL pointer before the teminating NULL. -- Erik Trulsson ertr1013@student.uu.se