• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdio.h>
17 #include <assert.h>
18 #include <info/fatal_message.h>
19 #include <unistd.h>
20 #include <sys/types.h>
21 #include <sys/wait.h>
22 
23 #undef assert
24 #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
25 
main(void)26 int main(void)
27 {
28     pid_t pid1;
29     int status;
30 
31     // Create the first child process
32     pid1 = fork();
33     if (pid1 < 0) {
34         // Failed to create the process
35         fprintf(stderr, "Fork failed for Process One\n");
36         return 1;
37     } else if (pid1 == 0) {
38         // Child process one
39         assert(0);
40         return 0;
41     }
42     waitpid(pid1, &status, 0);
43     return 0;
44 }