1 /**
2  * Copyright (c) 2022 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 <signal.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <sys/wait.h>
20 #include <unistd.h>
21 
22 #include "functionalext.h"
23 
24 /**
25  * @tc.name      : quick_exit_0100
26  * @tc.desc      : The main thread creates a child thread, the child thread calls quick exit to exit,
27  *                 and the child thread exit status is received in the child thread
28  * @tc.level     : Level 0
29  */
quick_exit_0100(void)30 void quick_exit_0100(void)
31 {
32     int status;
33     pid_t pid = fork();
34     if (pid == 0) {
35         sleep(1);
36         quick_exit(EXIT_SUCCESS);
37     } else if (pid > 0) {
38         wait(&status);
39         if (WIFEXITED(status)) {
40             EXPECT_EQ("quick_exit_0100", EXIT_SUCCESS, WEXITSTATUS(status));
41         }
42     } else {
43         t_error("Fork wrong\n");
44         exit(EXIT_FAILURE);
45     }
46 }
47 
main(void)48 int main(void)
49 {
50     quick_exit_0100();
51 
52     return t_status;
53 }
54