Please explain me the below code - Unix

This is a discussion on Please explain me the below code - Unix ; 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....

+ Reply to Thread
Results 1 to 8 of 8

Thread: Please explain me the below code

  1. 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.

  2. Re: Please explain me the below code

    On Nov 21, 7:25 am, kiran 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

  3. Re: Please explain me the below code

    On Nov 21, 6:10 pm, Lew Pitcher wrote:
    > On Nov 21, 7:25 am, kiran 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


    So will the select return if any signal arrives there?

  4. Re: Please explain me the below code

    On Nov 21, 9:03 am, kiran wrote:
    > On Nov 21, 6:10 pm, Lew Pitcher wrote:
    >
    > > On Nov 21, 7:25 am, kiran 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

    >
    > 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.

  5. Re: Please explain me the below code

    kiran writes:
    > On Nov 21, 6:10 pm, Lew Pitcher wrote:
    >> On Nov 21, 7:25 am, kiran 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

    >
    > So will the select return if any signal arrives there?


    If the signal is handled by the application, it should.

  6. Re: Please explain me the below code

    On Nov 21, 7:17 pm, Rainer Weikusat wrote:
    > kiran writes:
    > > On Nov 21, 6:10 pm, Lew Pitcher wrote:
    > >> On Nov 21, 7:25 am, kiran 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

    >
    > > So will the select return if any signal arrives there?

    >
    > 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?

  7. Re: Please explain me the below code

    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/

  8. Re: Please explain me the below code

    Lew Pitcher writes:
    >On Nov 21, 7:25 am, kiran 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


    sed -e "s/exactly/at least/"

    scott

+ Reply to Thread