Linuxϵͳµ÷ÓÃ
¹¦ÄÜÃèÊö£º
ÔÚÏûÏ¢¶ÓÁÐÉϽøÐÐÊÕ·¢ÏûÏ¢¡£ÎªÁË·¢ËÍÏûÏ¢£¬µ÷Óýø³Ì¶ÔÏûÏ¢¶ÓÁбØÐëÓÐдȨÄÜ¡£½ÓÊÕÏûϢʱ±ØÐëÓжÁȨÄÜ¡£
Ó÷¨£º
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
²ÎÊý£º
msqid£ºÏûÏ¢¶ÓÁеÄʶ±ðÂë¡£
msgp£ºÖ¸ÏòÏûÏ¢»º³åÇøµÄÖ¸Õ룬´ËλÖÃÓÃÀ´ÔÝʱ´æ´¢·¢ËͺͽÓÊÕµÄÏûÏ¢£¬ÊÇÒ»¸öÓû§¿É¶¨ÒåµÄͨÓýṹ£¬ÐÎ̬ÈçÏÂ
struct msgbuf {
long mtype; /* ÏûÏ¢ÀàÐÍ£¬±ØÐë > 0 */
char mtext[1]; /* ÏûÏ¢Îı¾ */
};
msgsz£ºÏûÏ¢µÄ´óС¡£
msgtyp£º´ÓÏûÏ¢¶ÓÁÐÄÚ¶ÁÈ¡µÄÏûÏ¢ÐÎ̬¡£Èç¹ûֵΪÁ㣬Ôò±íʾÏûÏ¢¶ÓÁÐÖеÄËùÓÐÏûÏ¢¶¼»á±»¶ÁÈ¡¡£
msgflg£ºÓÃÀ´Ö¸Ã÷ºËÐijÌÐòÔÚ¶ÓÁÐûÓÐÊý¾ÝµÄÇé¿öÏÂËùÓ¦²ÉÈ¡µÄÐж¯¡£Èç¹ûmsgflgºÍ³£ÊýIPC_NOWAITºÏÓã¬ÔòÔÚmsgsnd()Ö´ÐÐʱÈôÊÇÏûÏ¢¶ÓÁÐÒÑÂú£¬Ôòmsgsnd()½«²»»á×èÈû£¬¶ø»áÁ¢¼´·µ»Ø-1£¬Èç¹ûÖ´ÐеÄÊÇmsgrcv()£¬ÔòÔÚÏûÏ¢¶ÓÁгʿÕʱ£¬²»×öµÈ´ýÂíÉÏ·µ»Ø-1£¬²¢É趨´íÎóÂëΪENOMSG¡£µ±msgflgΪ0ʱ£¬msgsnd()¼°msgrcv()ÔÚ¶ÓÁгÊÂú»ò³Ê¿ÕµÄÇéÐÎʱ£¬²ÉÈ¡×èÈûµÈ´ýµÄ´¦Àíģʽ¡£
·µ»Ø˵Ã÷£º
³É¹¦Ö´ÐÐʱ£¬msgsnd()·µ»Ø0£¬msgrcv()·µ»Ø¿½±´µ½mtextÊý×éµÄʵ¼Ê×Ö½ÚÊý¡£Ê§°ÜÁ½Õ߶¼·µ»Ø-1£¬errno±»ÉèΪÒÔϵÄij¸öÖµ
[¶ÔÓÚmsgsnd]
EACCES£ºµ÷Óýø³ÌÔÚÏûÏ¢¶ÓÁÐÉÏûÓÐдȨÄÜ£¬Í¬Ê±Ã»ÓÐCAP_IPC_OWNERȨÄÜ
EAGAIN£ºÓÉÓÚÏûÏ¢¶ÓÁеÄmsg_qbytesµÄÏÞÖƺÍmsgflgÖÐÖ¸¶¨IPC_NOWAIT±êÖ¾£¬ÏûÏ¢²»Äܱ»·¢ËÍ
EFAULT£ºmsgpÖ¸ÕëÖ¸ÏòµÄÄÚ´æ¿Õ¼ä²»¿É·ÃÎÊ
EIDRM£ºÏûÏ¢¶ÓÁÐÒѱ»É¾³ý
EINTR£ºµÈ´ýÏûÏ¢¶ÓÁпռä¿ÉÓÃʱ±»ÐźÅÖжÏ
EINVAL£º²ÎÊýÎÞЧ
ENOMEM£ºÏµÍ³ÄÚ´æ²»×㣬ÎÞ·¨½«msgpÖ¸ÏòµÄÏûÏ¢¿½±´½øÀ´
[¶ÔÓÚmsgrcv]
E2BIG£ºÏûÏ¢Îı¾³¤¶È´óÓÚmsgsz£¬²¢ÇÒmsgflgÖÐûÓÐÖ¸¶¨MSG_NOERROR
EACCES£ºµ÷Óýø³ÌûÓжÁȨÄÜ£¬Í¬Ê±Ã»¾ßÓÐCAP_IPC_OWNERȨÄÜ
EAGAIN£ºÏûÏ¢¶ÓÁÐΪ¿Õ£¬²¢ÇÒmsgflgÖÐûÓÐÖ¸¶¨IPC_NOWAIT
EFAULT£ºmsgpÖ¸ÏòµÄ¿Õ¼ä²»¿É·ÃÎÊ
EIDRM£ºµ±½ø³Ì˯Ãߵȴý½ÓÊÕÏûϢʱ£¬ÏûÏ¢Òѱ»É¾³ý
EINTR£ºµ±½ø³Ì˯Ãߵȴý½ÓÊÕÏûϢʱ£¬±»ÐźÅÖжÏ
EINVAL£º²ÎÊýÎÞЧ
ENOMSG£ºmsgflgÖÐÖ¸¶¨ÁËIPC_NOWAIT£¬Í¬Ê±ËùÇëÇ
Ïà¹ØÎĵµ£º
±¾ÈËÔÚ½¨Á¢½»²æ±àÒë»·¾³ÊÇÓöµ½ÁËÒ»µãµãСÎÊÌâºÍÒÉÎʵ㣺
1¡¢Ê¹ÓÃÐéÄâ»úºÍPC»úÖ®¼ä¹²ÏíÎļþÊÇ£¨²»ÊÇÓù²ÏíĿ¼·½Ê½£©£¬´ÓPC¸´ÖÆÎļþµ½ÐéÄâ»ú¹²Ïí£¬¹²ÏíµÄÎļþ²»ÄÜÌ«´ó£¬¶øÕßÎļþÀïÃæ×îºÃ²»ÒªÓжà¸öÎļþ£¨¾¹È»ÓÐÕâÖÖÇé¿ö£©¡£
2¡¢ÔÚdebian2.6ÄÚºËÖÐÓÃvim±àд³ÌÐò±ÈÓÃviºÃ£¬ÓÃviʱ»áÒýÈëºÜ¶à´íÎóµÄ×Ö·û¡£
......
linux ÊØ»¤½ø³Ì
1.´´½¨×Ó½ø³Ì£¬¸¸½ø³ÌÍ˳ö
ÊØ»¤½ø³ÌÊÇÍÑÀëÖն˵ģ¬´ËʱµÄ×Ó½ø³ÌÓÉ1ºÅ½ø³ÌÁìÑø¡£
2.ÔÚ×Ó½ø³ÌÖд´½¨ÐµĻỰ
µ÷ÓÃsetsid£¨£©º¯Êý£¬×÷ÓÃÓÐÈý¸ö£¬Èýø³Ì°ÚÍÑԻỰµÄ¿ØÖÆ£»Èýø³Ì°ÚÍÑÔ½ø³Ì×éµÄ¿ØÖÆ£»
Èýø³Ì°ÚÍÑÔ¿ØÖÆÖն˵ĿØÖÆ
ÕâÀïÐèÒª½éÉܽø³Ì×éºÍ»á»°×éµÄ¸ÅÄî
½ø³Ì×飺ÊÇÒ»¸ö»ò¶à¸ö½ø³ÌµÄ¼¯ºÏ£¬Óɽ ......
·¢²¼: 2009-3-30 14:11 | ×÷Õß: gyl4802959
| À´Ô´: ITÔËάר¼ÒÍø
1)Ô¤±¸ÖªÊ¶
Nagios×Ô¼º¶¨ÒåÁËÒ»Ì×¹æÔòÓÃÓÚÅäÖÃÎļþ,ÆäÖÐ×îÖØÒªµÄ¸ÅÄî¾ÍÊÇ”¶ÔÏó”----object.ͨË×µÄÀí½â:¼Ù¶¨ÎÒÃÇÊ×Ïȶ¨ÒåÁË”ÐÔ±ð”Õâ¸ö¶ÔÏó,Ëü
µÄÖµÖ»¿ÉÄÜÊÇÄÐ,Å®,ÈËÑýµÈµÈ,È»ºó¶¨ÒåijÈËΪһ¸ö¶ÔÏó,ÀýÈçÕÅÈý,¶¨ÒåÕÅÈýµÄʱºòÓÐ ......