PDA

View Full Version : Sytem call internal and code



ankur0921
05-13-2010, 11:23 PM
Hi All,

How system call internals could be known ? I mean for example if i take the
example of write system call of linux kernel, where i can find out the code of
write() system call in the kernel source tree ? The problem is write() system
call directly write on console.If we want to write the data on some web page
then write() system call will not do that. How to redirect out data from console to application like html/web pages ? Can
anybody suggest something in this direction ?

Thanks in advance..

Ankur

Salem
05-14-2010, 03:51 AM
LXR / The Linux Cross Reference (http://lxr.linux.no/+trees)

> The problem is write() system call directly write on console
No it doesn't.
It writes wherever the file descriptor is set up to write to.

> If we want to write the data on some web page then write() system call will not do that
Yes it will, if you create a socket to your web site.
Then write() can send data to that site, via the socket.

> How to redirect out data from console to application like html/web pages ?
The close(), dup(), dup2() and pipe() calls are for manipulating file descriptors.

MK27
05-14-2010, 06:47 AM
In C/C++ on ALL operating systems, stdout (console output) is a file stream. You can just as easily use write() on a "real" file handle such as an html page as you can anything else, including stdout.

If you had used write() even once in actual coding, you would be aware of this. I would stay away from the kernel sources until you have at least a basic grasp of C syntax. You will just waste your time and end up horribly confused, as perhaps has already happened.