Date: Wed, 8 Apr 2009 09:55:15 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Mehul Chadha <mehulc87@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: working of syscall handling Message-ID: <20090408145515.GB90152@dan.emsphone.com> In-Reply-To: <251d650c0904080643o8789860w87c8cca070a16489@mail.gmail.com> References: <251d650c0904080643o8789860w87c8cca070a16489@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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<stdio.h> > > int readlink(void *a, void *b) > { > exit(0); > } > > int main(int argc, char **argv) > { > printf("Hello World"); > } -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090408145515.GB90152>