ELDK glibc fcntl(socketFd,F_SETFL, flags) causes Seg Fault

3 messages, 3 authors, 2007-02-02 · open the first message on its own page

ELDK glibc fcntl(socketFd,F_SETFL, flags) causes Seg Fault

From: Daniel Ng <hidden>
Date: 2007-02-01 23:08:25

Hi,

My application Seg Faults when I try to set flags for my socket fd.

First, I get the fd by calling socket():
fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

Then I try getting the fd flags:
fcntl(fd, F_GETFL, flags)

Then I try setting the flags:
flags |= O_NONBLOCK;
fcntl( fd, F_SETFL, flags );

-I get consistent Seg Faults on the last line above.

-I also checked fd, which is a sensible value. 
I can even successfully connect() with it.

-The problem happens regardless of what value 'flags' is set to


My embedded target details-

-powerpc8272
-ELDK v4
-the application uses glibc


Any ideas why I'm getting these Seg Faults?

Cheers,
Daniel

Re: ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault

From: Magnus Hjorth <hidden>
Date: 2007-02-02 15:03:59

Daniel Ng wrote:
Hi,

My application Seg Faults when I try to set flags for my socket fd.

Then I try getting the fd flags:
fcntl(fd, F_GETFL, flags)
  
Shouldn't it be &flags ??

-- 

Magnus Hjorth, M.Sc.
Omnisys Instruments AB
Gruvgatan 8
SE-421 30  Västra Frölunda, SWEDEN
Phone: +46 31 734 34 09
Fax: +46 31 734 34 29
http://www.omnisys.se 

RE: ELDK glibc fcntl(socketFd,F_SETFL, flags) causes Seg Fault

From: Edward Jubenville <hidden>
Date: 2007-02-02 15:13:35

Then I try getting the fd flags:
fcntl(fd, F_GETFL, flags)
Don't you really need to do this...

  flags = fcntl(fd, F_GETFL, 0)

to get the correct initial state of the flags?

Ed Jubenville
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help