Hi, I am afraid my post might have frustrated you. Let me explain a little more on the fact occured on my ThinkPad. I tried to excerpt a skelton of startup operations from libX as follows: socket() connect(); fcntl( ..., F_SETFD, FD_CLOEXEC ); writev(); and I found the last "writev" failed ( perror might say "Invalid argument" ), however, when I commented out the "fcntl" line, then it worked fine. According to the above fact, I doubted the "fcntl" system call in cygwin.dll but not libX. But, as you mentioned, it might be a special case occured in (my) ThinkPad. I will attach the skelton code I used in the test of communication to Xserver, and I hope this wouldn't violate mailing-list rules. Thank you for the great job on porting X environments to Windows. Shu Shimizu /*-------------------------------------------------------*/ #include <stdio.h> #include <sys/socket.h> #include <sys/uio.h> #include <sys/fcntl.h> #include <netinet/in.h> main(int argc, char** argv) { struct sockaddr_in saddr; struct iovec iov[2]; /* create a socket */ int s = socket(AF_INET,SOCK_STREAM,0/*IPPROTO_TCP*/); int tmp = 1; setsockopt (s, IPPROTO_TCP, TCP_NODELAY, (char *) &tmp, sizeof (int)); setsockopt (s, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp, sizeof (int)); fprintf(stderr,"socket = %d\n", s); bzero(&saddr,0,sizeof(saddr)); saddr.sin_family = AF_INET; saddr.sin_addr.s_addr = inet_addr("127.0.0.1"); saddr.sin_port = htons(6000); /* connect to the X server */ if (connect(s,(struct sockaddr*)&saddr,sizeof(saddr)) < 0) perror("connect"), exit(1); /* _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1) does the following */ if (1) { int ret = fcntl (s, F_SETFD, FD_CLOEXEC); fprintf(stderr,"ret = %d\n", ret); } /* meaningless data */ iov[0].iov_base = "Hogera"; iov[0].iov_len = 6; iov[1].iov_base = "Fugo"; iov[1].iov_len = 4; /* I would like to see the result from the below operation */ writev(s,iov,2); perror("writev"); /* perror reports "writev: Invalid argument", */ /* but "writev: error 0" when the fcntl commented out */ close(s); return 0; } /*-------------------------------------------------------*/

Reply via email to