From 688e29cf57651a3dd3c29abb5233c9d0fed775bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=AE=81?= Date: Wed, 5 Mar 2025 08:47:09 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20src/fork.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fork.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/fork.c diff --git a/src/fork.c b/src/fork.c new file mode 100644 index 0000000..8735881 --- /dev/null +++ b/src/fork.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int main () +{ + pid_t pid; + pid=fork(); + if (pid < 0) + printf("error in fork!"); + else if (pid == 0) + printf("i am the child process, my process id is %d\n",getpid()); + else + printf("i am the parent process, my process id is %d\n",getpid()); +}