Operating System - HP-UX
1745788 Members
4012 Online
108722 Solutions
New Discussion

Re: Passing file descriptor to an unrelated process using sendmsg call

 
T Kiran Kumar
New Member

Passing file descriptor to an unrelated process using sendmsg call

Hi,
I tried to pass an open file descriptor to a process (that is not a child of the current one i.e unrelated) using sendmsg call by filling the ancillary data structure cmsghdr. It is a simple program where a child process opens the file and passes it to the parent process. parent starts reading from it. The code works on Linux but on HP-UX, the sendmsg call fails saying EBADF: Bad file number error. The source code for the program is attached as modi_sendrcv_fd.c
I would like to know whether this feature of passing descriptors is possible in HP-UX. We need this for passing socket connection descriptor between unrelated processes. Please respond to this if there any suggestions.

Thanks
Kiran.
2 REPLIES 2
Martins99
New Member

Re: Passing file descriptor to an unrelated process using sendmsg call

Hello,

 

If you use the old POSIX1995 API (compile with -D_POSIX_C_SOURCE=199506L) it will work.

The api is also much simpler you just pass the file descriptor as msg_aarights,e.g.

 

#if _POSIX_VERSION < 200112L
    msg.msg_accrights = (caddr_t)&passfd;
    msg.msg_accrightslen = sizeof(passfd);

#else

 

But with POSIX 2001 and using ancillary data I have the same issue.

Did anyone manage to solve the issue with POSIX2001 on HPUX ?

 

 

 

shlomi1
New Member

Re: Passing file descriptor to an unrelated process using sendmsg call

Hi,

Any chance that someone solve it?

How do I need to call sendmsg using ancillary data?