¬getpgrpVcgLinuxÁªÃË
|
±íÍ·Îļþ | #include<unistd.h>VcgLinuxÁªÃË
|
¶¨Ò庯Êý | pid_t getpgid( pid_t pid);VcgLinuxÁªÃË
|
º¯Êý˵Ã÷ | getpgid()ÓÃÀ´È¡µÃ²ÎÊýpid Ö¸¶¨½ø³ÌËùÊôµÄ×éʶ±ðÂë¡£Èç¹û²ÎÊýpidΪ0£¬Ôò»áÈ¡µÃĿǰ½ø³ÌµÄ×éʶ±ðÂë¡£VcgLinuxÁªÃË
|
·µ»ØÖµ | Ö´Ðгɹ¦Ôò·µ»Ø×éʶ±ðÂ룬Èç¹ûÓдíÎóÔò·µ»Ø-1£¬´íÎóÔÒò´æÓÚerrnoÖС£VcgLinuxÁªÃË
|
´íÎó´úÂë | ESRCH ÕÒ²»µ½·ûºÏ²ÎÊýpid Ö¸¶¨µÄ½ø³Ì¡£VcgLinuxÁªÃË
|
·¶Àý | /*È¡µÃinit ½ø³Ì£¨pid£½1£©µÄ×éʶ±ðÂë*/VcgLinuxÁªÃË #include<unistd.h>VcgLinuxÁªÃË mian()VcgLinuxÁªÃË {VcgLinuxÁªÃË printf(¡°init gid = %dn¡±,getpgid(1));VcgLinuxÁªÃË }VcgLinuxÁªÃË
|
Ö´ÐÐ | init gid = 0VcgLinuxÁªÃË
|
| ¡¡ |
VcgLinuxÁªÃË
| VcgLinuxÁªÃË getpgrp£¨È¡µÃ½ø³Ì×éʶ±ðÂ룩 |
Ïà¹Øº¯Êý | setpgid£¬getpgid£¬getpgrpVcgLinuxÁªÃË
|
±íÍ·Îļþ | #include<unistd.h>VcgLinuxÁªÃË
|
¶¨Ò庯Êý | pid_t getpgrp(void);VcgLinuxÁªÃË
|
º¯Êý˵Ã÷ | getpgrp()ÓÃÀ´È¡µÃĿǰ½ø³ÌËùÊôµÄ×éʶ±ðÂë¡£´Ëº¯ÊýÏ൱ÓÚµ÷ÓÃgetpgid(0)£»VcgLinuxÁªÃË
|
·µ»ØÖµ | ·µ»ØÄ¿Ç°½ø³ÌËùÊôµÄ×éʶ±ðÂë¡£VcgLinuxÁªÃË
|
·¶Àý | #include<unistd.h>VcgLinuxÁªÃË main()VcgLinuxÁªÃË {VcgLinuxÁªÃË printf(¡°my gid =%dn¡±,getpgrp());VcgLinuxÁªÃË }VcgLinuxÁªÃË
|
Ö´ÐÐ | my gid =29546VcgLinuxÁªÃË
|
| ¡¡ |
VcgLinuxÁªÃË
| VcgLinuxÁªÃË getpid£¨È¡µÃ½ø³Ìʶ±ðÂ룩 |
Ïà¹Øº¯Êý | fork£¬kill£¬getpidVcgLinuxÁªÃË
|
±íÍ·Îļþ | #include<unistd.h>VcgLinuxÁªÃË
|
¶¨Ò庯Êý | pid_t getpid(void);VcgLinuxÁªÃË
|
º¯Êý˵Ã÷ | getpid£¨£©ÓÃÀ´È¡µÃĿǰ½ø³ÌµÄ½ø³Ìʶ±ðÂ룬Ðí¶à³ÌÐòÀûÓÃÈ¡µ½µÄ´ËÖµÀ´½¨Á¢ÁÙʱÎļþ£¬ÒÔ±ÜÃâÁÙʱÎļþÏàͬ´øÀ´µÄÎÊÌâ¡£VcgLinuxÁªÃË
|
·µ»ØÖµ | Ŀǰ½ø³ÌµÄ½ø³Ìʶ±ðÂëVcgLinuxÁªÃË
|
·¶Àý | #include<unistd.h>VcgLinuxÁªÃË main()VcgLinuxÁªÃË {VcgLinuxÁªÃË printf(¡°pid=%dn¡±,getpid());VcgLinuxÁªÃË }VcgLinuxÁªÃË
|
Ö´ÐÐ | pid=1494 /*ÿ´ÎÖ´Ðнá¹û¶¼²»Ò»¶¨Ïàͬ*/VcgLinuxÁªÃË
|
| ¡¡ |
VcgLinuxÁªÃË
| VcgLinuxÁªÃË getppid£¨È¡µÃ¸¸½ø³ÌµÄ½ø³Ìʶ±ðÂ룩 |
Ïà¹Øº¯Êý | fork£¬kill£¬getpidVcgLinuxÁªÃË
|
±íÍ·Îļþ | #include<unistd.h>VcgLinuxÁªÃË
|
¶¨Ò庯Êý | pid_t getppid(void);VcgLinuxÁªÃË
|
º¯Êý˵Ã÷ | getppid()ÓÃÀ´È¡µÃĿǰ½ø³ÌµÄ¸¸½ø³Ìʶ±ðÂë¡£VcgLinuxÁªÃË
|
·µ»ØÖµ | Ŀǰ½ø³ÌµÄ¸¸½ø³Ìʶ±ðÂë¡£VcgLinuxÁªÃË
|
·¶Àý | #include<unistd.h>VcgLinuxÁªÃË main()VcgLinuxÁªÃË {VcgLinuxÁªÃË printf(¡°My parent ¡®pid =%dn¡±,getppid());VcgLinuxÁªÃË }VcgLinuxÁªÃË
|
Ö´ÐÐ | My parent pid =463VcgLinuxÁªÃË
|
| ¡¡ |
VcgLinuxÁªÃË
| VcgLinuxÁªÃË getpriority£¨È¡µÃ³ÌÐò½ø³ÌÖ´ÐÐÓÅÏÈȨ£© |
Ïà¹Øº¯Êý | setpriority£¬niceVcgLinuxÁªÃË
|
±íÍ·Îļþ | #include<sys/time.h>VcgLinuxÁªÃË #include<sys/resource.h>VcgLinuxÁªÃË
|
¶¨Ò庯Êý | int getpriority(int which,int who);VcgLinuxÁªÃË
|
º¯Êý˵Ã÷ | getpriority()¿ÉÓÃÀ´È¡µÃ½ø³Ì¡¢½ø³Ì×éºÍÓû§µÄ½ø³ÌÖ´ÐÐÓÅÏÈȨ¡£VcgLinuxÁªÃË
|
²ÎÊý | whichÓÐÈýÖÖÊýÖµ£¬²ÎÊýwho ÔòÒÀwhichÖµÓв»Í¬¶¨ÒåVcgLinuxÁªÃË which who ´ú±íµÄÒâÒåVcgLinuxÁªÃË PRIO_PROCESS who Ϊ½ø³Ìʶ±ðÂëVcgLinuxÁªÃË PRIO_PGRP who Ϊ½ø³ÌµÄ×éʶ±ðÂëVcgLinuxÁªÃË PRIO_USER who ΪÓû§Ê¶±ðÂëVcgLinuxÁªÃË ´Ëº¯Êý·µ»ØµÄÊýÖµ½éÓÚ-20 ÖÁ20Ö®¼ä£¬´ú±í½ø³ÌÖ´ÐÐÓÅÏÈȨ£¬ÊýÖµÔ½µÍ´ú±íÓнϸߵÄÓÅÏÈ´ÎÐò£¬Ö´Ðлá½ÏƵ·±¡£VcgLinuxÁªÃË
|
·µ»ØÖµ | ·µ»Ø½ø³ÌÖ´ÐÐÓÅÏÈȨ£¬ÈçÓдíÎó·¢Éú·µ»ØÖµÔòΪ-1 ÇÒ´íÎóÔÒò´æÓÚerrno¡£VcgLinuxÁªÃË
|
¸½¼Ó˵Ã÷ | ÓÉÓÚ·µ»ØÖµÓпÉÄÜÊÇ-1£¬Òò´ËҪͬʱ¼ì²éerrnoÊÇ·ñ´æÓдíÎóÔÒò¡£×îºÃÔÚµ÷Óôκ¯ÊýǰÏÈÇå³ýerrno±äÁ¿¡£VcgLinuxÁªÃË
|
´íÎó´úÂë | ESRCH ²ÎÊýwhich»òwho ¿ÉÄÜÓÐ´í£¬¶øÕÒ²»µ½·ûºÏµÄ½ø³Ì¡£EINVAL ²ÎÊýwhich Öµ´íÎó¡£VcgLinuxÁªÃË
|
| ¡¡ |
VcgLinuxÁªÃË
| VcgLinuxÁªÃË nice£¨¸Ä±ä½ø³ÌÓÅÏÈ˳Ðò£© |
Ïà¹Øº¯Êý | setpriority£¬getpriorityVcgLinuxÁªÃË
|
±íÍ·Îļþ | #include<unistd.h>VcgLinuxÁªÃË
|
¶¨Ò庯Êý | int nice(int inc);VcgLinuxÁªÃË
|
º¯Êý˵Ã÷ | nice()ÓÃÀ´¸Ä±ä½ø³ÌµÄ½ø³ÌÖ´ÐÐÓÅÏÈ˳Ðò¡£²ÎÊýincÊýÖµÔ½´óÔòÓÅÏÈ˳ÐòÅÅÔÚÔ½ºóÃæ£¬¼´±íʾ½ø³ÌÖ´ÐлáÔ½Âý¡
|
|
|