Chinaunix

标题: [HP-UX 11.0]EFAULT error in msgrcv() function [打印本页]

作者: grace_limi    时间: 2003-03-18 11:02
标题: [HP-UX 11.0]EFAULT error in msgrcv() function
[HP-UX 11.0]

Recently a fatal error was encountered in one process of our HP-UX 11.0 system while the msgrcv() function was called. The error # is 14 - EFAULT. From the man page the explanation of the error is:

[EFAULT]msgp points to an illegal address.  The reliable detection of this error is implementation dependent.

However, I am confused by what causes such an error. Please check our source codes listed as below:

#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <gnrl/gnrlmsgtypes.h>
#include <gnrl/gnrlmsglib.h>
#include <gnrl/mt.h>
#include <gnrl/gnrlgerrnums.h>
#include <gnrl/gnrlparams.h>
#include \"ipctools.h\"

extern int My_uid;
extern int errno;
extern key_t get_qid();

#define FUNC \"gmsg_recv.c\"

gmsg_recv( msg )
        struct msgbuff *msg;
{
        static key_t qid = 0;

        /* If i don\'t know my id */
        if( qid == 0 )
        {
                /* Find out what queue id corresponds to my user id */
                qid = get_qid( My_uid, FUNC );
        }
        /* Block waiting for a msg */
        while( msgrcv( qid, msg, HEADER + MAX_MSG_DATA_SIZE, -PRI_20, 0) < 0 )
        {
                if( errno == EINTR )
                {
                        errno = 0;
                        continue;
                }
                ginterr( MSG_RECV_ERROR, errno, (int *)0, (int *)0, (int *)0,
                                (int *)0, FUNC, 1 );
                exit( 1 );
        }
}




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2