• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2022 Huawei Device Co., Ltd.
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  *     http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 #include <stdlib.h>
16 #include <time.h>
17 #include <stdio.h>
18 #include <signal.h>
19 #include "test.h"
20 
21 extern int __sigtimedwait_time64(const sigset_t *restrict mask,
22                                 siginfo_t *restrict si,
23                                 const struct timespec *restrict timeout);
24 
25 /**
26  * @tc.name      : sigtimedwait_0100
27  * @tc.desc      : Test sigtimedwait method
28  * @tc.level     : Level 1
29  */
sigtimedwait_0100(void)30 void sigtimedwait_0100(void)
31 {
32     sigset_t set;
33     pid_t pid;
34     sigemptyset(&set);
35     sigaddset(&set, SIGCHLD);
36     sigprocmask(SIG_BLOCK, &set, NULL);
37     pid = fork();
38     if( pid == -1) {
39         exit(1);
40     } else if( pid ) {
41         sigset_t set2;
42         siginfo_t siginfo;
43         struct timespec timeout = {3, 0};
44         int signal;
45         sigemptyset(&set2);
46         sigaddset(&set2, SIGCHLD);
47         signal = sigtimedwait(&set2, &siginfo, &timeout);
48         if (signal < 0) {
49             t_error( "%s sigtimedwait error get result is %d\n", __func__, signal);
50         }
51     }
52 }
53 
54 /**
55  * @tc.name      : sigtimedwait_time64_0100
56  * @tc.desc      : Test __sigtimedwait_time64 method
57  * @tc.level     : Level 1
58  */
sigtimedwait_time64_0100(void)59 void sigtimedwait_time64_0100(void)
60 {
61     sigset_t set;
62     pid_t pid;
63     sigemptyset(&set);
64     sigaddset(&set, SIGCHLD);
65     sigprocmask(SIG_BLOCK, &set, NULL);
66     pid = fork();
67     if( pid == -1) {
68         exit(1);
69     } else if( pid ) {
70         sigset_t set2;
71         siginfo_t siginfo;
72         struct timespec timeout = {3, 0};
73         int signal;
74         sigemptyset(&set2);
75         sigaddset(&set2, SIGCHLD);
76         signal = __sigtimedwait_time64(&set2, &siginfo, &timeout);
77         if (signal < 0) {
78             t_error( "%s __sigtimedwait_time64 error get result is %d\n", __func__, signal);
79         }
80     }
81 }
82 
main()83 int main()
84 {
85     sigtimedwait_0100();
86     sigtimedwait_time64_0100();
87     return t_status;
88 }