1847253 Members
4015 Online
110263 Solutions
New Discussion

Regarding HPUX10.2

 
Soumya_2
New Member

Regarding HPUX10.2

Observation - Execution of 'system()' system call after the 'accept()' system call results in
the blocking of threads existing in that process on executing another 'accept()' call.

Detailed Explanation -
The RemoteServer('server' executable) is started. The RemoteServer accepts connections from a client. When the RemoteServer accepts a connection for the first time, a parallel thread is started which isan infinite loop. After starting the thread, a "system()" function is executed.The next connection request by the client results in the thread in the RemoteServer getting blocked.
Other Operating systems like HPUX 11.0,Sun Solaris 2.6 and Aix4.2 do not block the
thread after any number of connections.
However, removing the "system()" function from the code on HPUX10.2 allows further
connections without blocking or killing the thread.

Note : We use cma library to compile the RemoteServer code to support pthread_create call in
HPUX10.2 (ie. we compile the code using the -lcma option).

Query -
1) Is there a relation between the "accept" system call and the "system" system call which
results in any thread existing in that process from getting blocked or killed ?
2) Is the above phenomenon because of the usage of cma library to support pthread_create ?
3) Do we have to use any particular value for the attribute parameter in the pthread_create
call ? (We use pthread_attr_default in our pthread_create call.)

Note : Please refer to file ServerCode.doc for diagramatic explanation
of problem area in code.
2 REPLIES 2
Pete Conneely
Advisor

Re: Regarding HPUX10.2

I found the following information extracted from an earlier call, but I am not sure if it is exactly your situation. Worth reviewing anyway:
"
There is a documented workaround for an accept()/system() call problem.
It is to use an fcntl call to set the close-on-exec flag before calling exec() (which select() is a thin wrapper for anyway; fork/exec/wait). This is documented in "Programming with Threads on HP-UX" in section 3.2.1.6 on page 3-16.
The other option would be to avoid using the select call and calling exec directly
rather than the exec wrapper, also documented in the same section.
The fcntl can be used soon after the socket is created.
.......
sock = socket(AF_INET,SOCK_STREAM, 0);
if (sock == -1) {
fprintf(stderr, "socket failed, errno %dn", errno);
return -1;
}
fcntl(sock,F_SETFD,FD_CLOEXEC);
......
cma___pre_exec_cleanup() (internal routine) sets the file-descriptors
to blocking mode.

A change in the code would involve calling set_blocking every time in
the accept() wrapper and that may lead to decreased performance. For
this reason we recommend close-on-exec as a documented workaround.
"


There is some excellent threads FAQs and manuals info at URL:
http://devresource.hp.com/

You must go there....there is some good detailed info.

I hope this helps.
Soumya_2
New Member

Re: Regarding HPUX10.2

Hi Peter,
Thanks for your suggestion about using fcntl(). Our program did work for the second accept(). It was very kind of you to give us this solution
Thank you
Soumya