|
Home > Archive > Unix Programming > November 2007 > Please explain me the below code
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Please explain me the below code
|
|
|
| Hello,
Could anyone please explain me the below code, what exactly it will do
fd_set fds;
FD_ZERO(&fds);
struct timeval tv;
tv.tv_sec=5;
tv.tv_usec=1000;
select(0, &fds, &fds, &fds, &tv);
Please help me asap.
Thanks in advance.
-Kiran.
| |
| Lew Pitcher 2007-11-21, 7:32 am |
| On Nov 21, 7:25 am, kiran <edu....@gmail.com> wrote:
> Hello,
>
> Could anyone please explain me the below code, what exactly it will do
>
> fd_set fds;
> FD_ZERO(&fds);
> struct timeval tv;
> tv.tv_sec=5;
> tv.tv_usec=1000;
> select(0, &fds, &fds, &fds, &tv);
In simple terms, this code uses a side-effect of the select(2) syscall
in order to introduce a timed delay of exactly 5.001 seconds
| |
|
| On Nov 21, 6:10 pm, Lew Pitcher <lpitc...@teksavvy.com> wrote:
> On Nov 21, 7:25 am, kiran <edu....@gmail.com> wrote:
>
>
>
>
> In simple terms, this code uses a side-effect of the select(2) syscall
> in order to introduce a timed delay of exactly 5.001 seconds
So will the select return if any signal arrives there?
| |
| Lew Pitcher 2007-11-21, 1:25 pm |
| On Nov 21, 9:03 am, kiran <edu....@gmail.com> wrote:
> On Nov 21, 6:10 pm, Lew Pitcher <lpitc...@teksavvy.com> wrote:
>
>
>
>
>
>
> So will the select return if any signal arrives there?
No, because it does not name any filedescriptors to select against.
a) the list of filedescriptors to check (fds) is set to zero, and
b) the count of filedescriptors to check is set to zero (the 1st parm
in the select() call)
So, select() has no filedescriptors to check, and only has a timeout
value.
| |
| Rainer Weikusat 2007-11-21, 1:25 pm |
| kiran <edu.mvk@gmail.com> writes:
> On Nov 21, 6:10 pm, Lew Pitcher <lpitc...@teksavvy.com> wrote:
>
> So will the select return if any signal arrives there?
If the signal is handled by the application, it should.
| |
|
| On Nov 21, 7:17 pm, Rainer Weikusat <rweiku...@mssgmbh.com> wrote:
> kiran <edu....@gmail.com> writes:
>
>
>
>
>
>
> If the signal is handled by the application, it should.- Hide quoted text -
>
> - Show quoted text -
Actually i have different signal handlers, but i want to return that
select() only for a particular signal arrives.. how can i acheive this?
| |
| James Antill 2007-11-21, 7:21 pm |
| On Wed, 21 Nov 2007 06:33:57 -0800, kiran wrote:
> Actually i have different signal handlers, but i want to return that
> select() only for a particular signal arrives.. how can i acheive this?
pselect
--
James Antill -- james@and.org
C String APIs use too much memory? ustr: length, ref count, size and
read-only/fixed. Ave. 44% overhead over strdup(), for 0-20B strings
http://www.and.org/ustr/
| |
| Scott Lurndal 2007-11-26, 7:22 pm |
| Lew Pitcher <lpitcher@teksavvy.com> writes:
>On Nov 21, 7:25 am, kiran <edu....@gmail.com> wrote:
>
>In simple terms, this code uses a side-effect of the select(2) syscall
>in order to introduce a timed delay of exactly 5.001 seconds
sed -e "s/exactly/at least/"
scott
|
|
|
|
|