OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / release / man2 / getpid.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki
25 .\"     and Copyright(c) 2008 Akihiro MOTOKI
26 .\"         all rights reserved.
27 .\" Translated Thu Jun 26 20:33:01 JST 1997
28 .\"         by SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
29 .\" Updated 2008-10-03, Akihiro MOTOKI, LDP v3.10
30 .\"
31 .TH GETPID 2 2008-09-23 "Linux" "Linux Programmer's Manual"
32 .SH Ì¾Á°
33 getpid, getppid \- ¥×¥í¥»¥¹ ID ¤òÆÀ¤ë
34 .SH ½ñ¼°
35 .B #include <sys/types.h>
36 .br
37 .B #include <unistd.h>
38 .sp
39 .B pid_t getpid(void);
40 .br
41 .B pid_t getppid(void);
42 .SH ÀâÌÀ
43 .BR getpid ()
44 ¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤òÊÖ¤¹¡£(¥Æ¥ó¥Ý¥é¥êÍѤΥե¡¥¤¥ë̾¤È¤·¤Æ
45 ¾¤È½Å¤Ê¤é¤Ê¤¤Ì¾Á°¤òÀ¸À®¤¹¤ë¥ë¡¼¥Á¥ó¤Ç¤·¤Ð¤·¤Ð»ÈÍѤµ¤ì¤ë¡£)
46
47 .BR getppid ()
48 ¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¿Æ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤òÊÖ¤¹¡£
49 .SH ¥¨¥é¡¼
50 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¾ï¤ËÀ®¸ù¤¹¤ë¡£
51 .SH ½àµò
52 POSIX.1-2001, 4.3BSD, SVr4.
53 .SH Ãí°Õ
54 glibc ¥Ð¡¼¥¸¥ç¥ó 2.3.4 °Ê¹ß¤Ç¤Ï¡¢
55 glibc ¤Î
56 .BR getpid ()
57 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï PID ¤ò¥­¥ã¥Ã¥·¥å¤¹¤ë¡£
58 ¤³¤ì¤Ï¡¢¥×¥í¥»¥¹¤¬·«¤êÊÖ¤·
59 .BR getpid ()
60 ¤ò¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¤Ë¤½¤ÎÅÔÅÙ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ö¤Î¤òÈò¤±¤ë¤¿¤á¤Ç¤¢¤ë¡£
61 Ä̾ï¤Ï¡¢¤³¤Î¥­¥ã¥Ã¥·¥å½èÍý¤¬¸«¤¨¤ë¤³¤È¤Ï¤Ê¤¤¤¬¡¢
62 ¥­¥ã¥Ã¥·¥å½èÍý¤¬Àµ¤·¤¯Æ¯¤¯¤¿¤á¤Ë¤Ï
63 .BR fork (2),
64 .BR vfork (2),
65 .BR clone (2)
66 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤Î¥µ¥Ý¡¼¥È¤¬É¬ÍפǤ¢¤ë¡£
67 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤¹ºÝ¤Ë¡¢
68 glibc ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤ò·Ðͳ¤»¤º¤Ë
69 .BR syscall (2)
70 ¤ò»È¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢»Ò¥×¥í¥»¥¹¤Ç
71 .BR getpid ()
72 ¤ò¸Æ¤Ó½Ð¤¹¤È´Ö°ã¤Ã¤¿Ãͤ¬Ê֤뤳¤È¤À¤í¤¦
73 (Àµ³Î¤Ë¤¤¤¦¤È¡¢¿Æ¥×¥í¥»¥¹¤Î PID ¤¬ÊÖ¤µ¤ì¤ë)¡£
74 .\" The following program demonstrates this "feature":
75 .\"
76 .\" #define _GNU_SOURCE
77 .\" #include <sys/syscall.h>
78 .\" #include <sys/wait.h>
79 .\" #include <stdio.h>
80 .\" #include <stdlib.h>
81 .\" #include <unistd.h>
82 .\"
83 .\" int
84 .\" main(int argc, char *argv[])
85 .\" {
86 .\"    /* The following statement fills the getpid() cache */
87 .\"
88 .\"    printf("parent PID = %ld\n", (long) getpid());
89 .\"
90 .\"    if (syscall(SYS_fork) == 0) {
91 .\"        if (getpid() != syscall(SYS_getpid))
92 .\"            printf("child getpid() mismatch: getpid()=%ld; "
93 .\"                    "syscall(SYS_getpid)=%ld\n",
94 .\"                    (long) getpid(), (long) syscall(SYS_getpid));
95 .\"        exit(EXIT_SUCCESS);
96 .\"    }
97 .\"    wait(NULL);
98 .\"}
99 .BR clone (2)
100 ¤ò glibc ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô·Ðͳ¤Çµ¯Æ°¤·¤¿ºÝ¤Ë¤â
101 .BR getpid ()
102 ¤¬´Ö°ã¤Ã¤¿ÃͤòÊÖ¤¹¾ì¹ç¤¬¤¢¤ê¡¢¤³¤ì¤Ë´Ø¤¹¤ëµÄÏÀ¤Ï
103 .BR clone (2)
104 ¤â»²¾È¤·¤Æ¤Û¤·¤¤¡£
105 .SH ´ØÏ¢¹àÌÜ
106 .BR clone (2),
107 .BR fork (2),
108 .BR kill (2),
109 .BR exec (3),
110 .BR mkstemp (3),
111 .BR tempnam (3),
112 .BR tmpfile (3),
113 .BR tmpnam (3),
114 .BR credentials (7)