From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 8 14:55:18 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6B3F106567D for ; Wed, 8 Apr 2009 14:55:18 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id 9AE428FC2C for ; Wed, 8 Apr 2009 14:55:18 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id n38EtHsM058316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 8 Apr 2009 09:55:18 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id n38EtHqB040081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 8 Apr 2009 09:55:17 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id n38EtF0N040078; Wed, 8 Apr 2009 09:55:15 -0500 (CDT) (envelope-from dan) Date: Wed, 8 Apr 2009 09:55:15 -0500 From: Dan Nelson To: Mehul Chadha Message-ID: <20090408145515.GB90152@dan.emsphone.com> References: <251d650c0904080643o8789860w87c8cca070a16489@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <251d650c0904080643o8789860w87c8cca070a16489@mail.gmail.com> X-OS: FreeBSD 7.1-STABLE User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: ClamAV version 0.94.1, clamav-milter version 0.94.1 on email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Wed, 08 Apr 2009 09:55:18 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: freebsd-hackers@freebsd.org Subject: Re: working of syscall handling 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: Wed, 08 Apr 2009 14:55:19 -0000 In the last episode (Apr 08), Mehul Chadha said: > In the program given below the function readlink gets called up when > printf is executed and the program ends without any output. > > readlink is a system call (syscall number = 58) which is being made by the > printf function, but according to my understanding of system call, it is > made by putting the handler number in eax register and then interrupting > the processor, so that it can enter the kernel mode and execute the > required function, but in this case(dont know why) my readlink function > gets called up which should not have happened. Readlink is not only a syscall, but a POSIX library function. You are overriding that, and FreeBSD's malloc function uses readlink to read the /etc/malloc.conf settings file. printf calls malloc, so that's why your program exits. http://www.opengroup.org/onlinepubs/9699919799/functions/readlink.html > I will be very thankful if you can help me with it. > > #include > > int readlink(void *a, void *b) > { > exit(0); > } > > int main(int argc, char **argv) > { > printf("Hello World"); > } -- Dan Nelson dnelson@allantgroup.com