lkml.org 
[lkml]   [1997]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: interesting behavior.. this right ?
Date
> > 	printf("connecting...\n");
>
> signal(SIGALRM, dummy);
> alarm(5);
> >
> > if (connect(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) < 0)
> > perror("connect");
>
> These modifications will get you out of any system call. If the connection
> failed, the errno will be "interrupted system call", when tha alarm clock

These modifications don't work. This is the prehistoric V7 sleep bug. You
have no guarantee that the alarm will not go off before connect() is called.
At that point you lose. Instead you need to do something more like this


void foo_func()
{
siglongjmp(...)
}

and ..

if(sigsetjmp(....))
return TIMEOUT;
signal(SIGALRM, foo_func);
alarm(5);
if(connect(...


\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.027 / U:0.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site