kcmp

KCMP(2)                    Linux Programmer's Manual                   KCMP(2)



åå
       kcmp - äºã¤ã®ããã»ã¹ãåãã«ã¼ãã«ãªã½ã¼ã¹ãå±æãã¦ããããæ¯è¼ãã

æ¸å¼
       #include <linux/kcmp.h>

       int kcmp(pid_t pid1, pid_t pid2, int type,
                unsigned long idx1, unsigned long idx2);

       注: ãã®ã·ã¹ãã ã³ã¼ã«ã«ã¯ glibc ã®ã©ããã¼é¢æ°ã¯åå¨ããªããã注æãã®ç¯ãåç§ã

説æ
       ã·ã¹ãã ã³ã¼ã« kcmp() ã使ãã¨ã ID ã pid1 㨠pid2 ã®äºã¤ã®ããã»ã¹ãã
       ä»®æ³ã¡ã¢ãªã¼ããã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ãªã©ã®ã
       åãã«ã¼ãã«ãªã½ã¼ã¹ãå±æãã¦ãããã©ãããæ¤æ»ã§ããã

       type å¼ãæ°ã¯ 2 ã¤ã®ããã»ã¹éã§ã©ã®ãªã½ã¼ã¹ãæ¯è¼ããããæå®ããã
       以ä¸ã®ããããã®å¤ãæå®ããã

       KCMP_FILE
              ããã»ã¹ pid1 ã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ idx1 ãã ããã»ã¹ pid2
              ã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ idx2 ã¨åããªã¼ãã³ãã¡ã¤ã«è¨è¿° (open file
              description) ãåç§ãã¦ããããæ¤æ»ããã

       KCMP_FILES
              äºã¤ã®ããã»ã¹ãåããªã¼ãã³ãã¡ã¤ã«è¨è¿°ã®éåãå±æãã¦ããããæ¤æ»ããã å¼ãæ°
              idx1 㨠idx2 ã¯ç¡è¦ãããã

       KCMP_FS
              äºã¤ã®ããã»ã¹ãåããã¡ã¤ã«ã·ã¹ãã æå ±
              (ããªãã¡ããã¡ã¤ã«ã®ã¢ã¼ãä½æãã¹ã¯ãä½æ¥‐
              ãã£ã¬ã¯ããªããã¡ã¤ã«ã·ã¹ãã ã®ã«ã¼ã) ãå±æãã¦ããããæ¤æ»ããã å¼ãæ° idx1
              㨠idx2 ã¯ç¡è¦ãããã

       KCMP_IO
              äºã¤ã®ããã»ã¹ã I/O ã³ã³ããã¹ããå±æãã¦ããããæ¤æ»ããã å¼ãæ° idx1 㨠idx2
              ã¯ç¡è¦ãããã

       KCMP_SIGHAND
              äºã¤ã®ããã»ã¹ãã·ã°ãã«éé (disposition) ãã¼ãã«ãå±æãã¦ããããæ¤æ»ããã
              å¼ãæ° idx1 㨠idx2 ã¯ç¡è¦ãããã

       KCMP_SYSVSEM
              äºã¤ã®ããã»ã¹ãåã System V ã»ããã© undo
              æä½ã®ãªã¹ããå±æãã¦ããããæ¤æ»ããã å¼ãæ° idx1 㨠idx2 ã¯ç¡è¦ãããã

       KCMP_VM
              äºã¤ã®ããã»ã¹ãåãã¢ãã¬ã¹ç©ºéãå±æãã¦ããããæ¤æ»ããã å¼ãæ° idx1 㨠idx2
              ã¯ç¡è¦ãããã

       kcmp() ã«ã¯ãã¿ã¹ã¯ãå®è¡ããã¦ããå ´åã«èµ·ããå¾ã誤å¤å® (false positive)
       ã«é¢ããä¿è·ã¯ãªãã ã¨ãããã¨ã¯ã æå³ã®ããçµæãå¾ãããã«ã¯ã
       ãã®ã·ã¹ãã ã³ã¼ã«ã§æ¤æ»ãè¡ãåã«ã SIGSTOP ãéä¿¡ãã¦ã¿ã¹ã¯ãåæ‐
       ¢ãã¹ãã ã¨ãããã¨ã  (signal(7) åç§)ã

è¿ãå¤
       kcmp()
       ã®å¼ã³åºããæåããå ´åã®è¿ãå¤ã¯ãåã«ã«ã¼ãã«ãã¤ã³ã¿ã¼ãæ°å¤ã§æ¯è¼ããçµæã¨ãªã
       (ã«ã¼ãã«ã¯ãªã½ã¼ã¹ãæ¯è¼ããéããªã½ã¼ã¹ã®ã¡ã¢ãªã¼ã¢ãã¬ã¹ã使ç¨ãã)ã

       ããã説æããã«ã¯ãä¾ãè¦ãã®ãä¸çªç°¡åã§ããã v1 㨠v2
       ãé©åãªãªã½ã¼ã¹ã®ã¢ãã¬ã¹ã¨ããã¨ã è¿ãå¤ã¯ä»¥ä¸ã®ããããä¸ã¤ã¨ãªãã

           0   v1 㯠v2 ã¨çãããè¨ãæããã°ãäºã¤ã®ããã»ã¹ã¯ãã®ãªã½ã¼ã¹ãå±æãã¦ããã

           1   v1 㯠v2 ããå°ããã

           2   v1 㯠v2 ãã大ããã

           3   v1 㯠v2 ã¨çãããªãããé åºæå ±ããªãã

       ã¨ã©ã¼ã®å ´å㯠-1 ãè¿ããã errno ãé©åã«è¨å®ãããã

       kcmp() ã¯ãã½ã¼ãã«é©ããå¤ãè¿ãããã«è¨è¨ãããã
       大éã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ãæ¯è¼ããå¿è¦ãããå ´åã«ãç¹ã«å½¹ã«ç«ã¤ã

ã¨ã©ã¼
       EBADF  type ã KCMP_FILE ã§ãã㤠fd1 ã fd2 ããªã¼ãã³ãã¡ã¤ã«è¨è¿°ã§ãªãã

       EINVAL type ãç¡å¹ã§ããã

       EPERM  ããã»ã¹ã®ãªã½ã¼ã¹ãæ¤æ»ããã®ã«ååãªè¨±å¯ããªãã èªåãææãã¦ããªããã‐
              ã»ã¹ãæ¤æ»ããããã«ã¯ CAP_SYS_PTRACE ã±ã¼ãããªãã£ãå¿è¦ã§ããã

       ESRCH  ããã»ã¹ pid1 ã pid2 ãåå¨ããªãã

ãã¼ã¸ã§ã³
       kcmp() ã·ã¹ãã ã³ã¼ã«ã¯ Linux 3.5 ã§åãã¦ç»å ´ããã

æºæ
       kcmp() 㯠Linux ç¹æã§ããã 移æ¤ãèæ®ããããã°ã©ã ã§ã¯ä½¿ç¨ãã¹ãã§ã¯ãªãã

注æ
       glibc ã¯ãã®ã·ã¹ãã ã³ã¼ã«ã«å¯¾ããã©ããã¼é¢æ°ãæä¾ãã¦ããªãã syscall(2)
       ã使ã£ã¦å¼ã³åºããã¨ã

       ãã®ã·ã¹ãã ã³ã¼ã«ãå©ç¨ã§ããã®ã¯ã ã«ã¼ãã«ã® CONFIG_CHECKPOINT_RESTORE
       ãªãã·ã§ã³ãæå¹ã«ãªã£ã¦ããå ´åã ãã§ããã ãã®ã·ã¹ãã ã³ã¼ã«ã®ä¸»ãªç¨éã¯ã
       ã¦ã¼ã¶ã¼ç©ºéã§ã®ãã§ãã¯ãã¤ã³ã/ãªã¹ã㢠(checkpoint/restore in user space;
       CRIU) æ©è½ã§ããã ãã®ã·ã¹ãã ã³ã¼ã«ã使ããªãã¨ããã¨ã proc(5)
       ãã¡ã¤ã«ã·ã¹ãã çµç±ã§å¿è¦ãªããã»ã¹æå ±ãå¬éãããã¨ã«ãªããã ããã¯ã»ã‐
       ã¥ãªãã£ä¸ã®çç±ããä¸é©åã¨ã¿ãªãããã

       ãã®ãã¼ã¸ã§åç§ããã¦ããå±æãªã½ã¼ã¹ã«é¢ããèæ¯ã«ã¤ãã¦ã®æå ±ã¯ clone(2)
       ãåç§ã®ãã¨ã

é¢é£é ç®
       clone(2), unshare(2)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.79 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



Linux                             2013-12-08                           KCMP(2)