![]() |
![]() |
|
|||||||
| Register | Forum Rules | Getting Started! - Guide | Blog | Videos | Gallery | Members List | Social Groups | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Return value of successful open call
Return value of successful open call is non negative integer. Thats
mean zero can be file descriptor. Is this a special file descriptor or zero can be a file descriptor for a regular file. Can someone highlight on this. Regards, Paresh |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Return value of successful open call
2007-11-05, 09:02(-00), paresh:
> Return value of successful open call is non negative integer. Thats > mean zero can be file descriptor. Is this a special > file descriptor or zero can be a file descriptor for a regular file. > > Can someone highlight on this. [...] By convention, file descriptors 0, 1 and 2 are used as the default fd to read data from, write data to and write error to respectively (called stdin, stdout, stderr). Most applications assume they are already open when you start them, so that it's generally an error condition for them if they are not. Applications like getty/xterm/... generally open the 3 of them to your terminal and shell redirection operators for instance can reassign them to something else. Functions like scanf, gets, puts, printf... read from fd 0 and write to fd 1. But appart from that, they are like any other fds. So for instance a daemon can use them as any other fds (though you'll find some tend to open /dev/null on them to avoid side effects in case they run other commands). -- Stéphane |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Return value of successful open call
On Nov 5, 3:06 pm, Stephane CHAZELAS <this.addr...@is.invalid> wrote:
> 2007-11-05, 09:02(-00), paresh:> Return value of successful open call is non negative integer. Thats > > mean zero can be file descriptor. Is this a special > > file descriptor or zero can be a file descriptor for a regular file. > > > Can someone highlight on this. > > [...] > > By convention, file descriptors 0, 1 and 2 are used as the > default fd to read data from, write data to and write error to > respectively (called stdin, stdout, stderr). Most applications > assume they are already open when you start them, so that it's > generally an error condition for them if they are not. > Applications like getty/xterm/... generally open the 3 of them > to your terminal and shell redirection operators for instance > can reassign them to something else. Functions like scanf, gets, > puts, printf... read from fd 0 and write to fd 1. > > But appart from that, they are like any other fds. So for > instance a daemon can use them as any other fds (though you'll > find some tend to open /dev/null on them to avoid side effects > in case they run other commands). > > -- > Stéphane Thanks Paresh |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Home - Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |