| 1 |
/**************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* This file is part of Frama-C. */ |
| 4 |
/* */ |
| 5 |
/* Copyright (C) 2007-2022 */ |
| 6 |
/* CEA (Commissariat à l'énergie atomique et aux énergies */ |
| 7 |
/* alternatives) */ |
| 8 |
/* */ |
| 9 |
/* you can redistribute it and/or modify it under the terms of the GNU */ |
| 10 |
/* Lesser General Public License as published by the Free Software */ |
| 11 |
/* Foundation, version 2.1. */ |
| 12 |
/* */ |
| 13 |
/* It is distributed in the hope that it will be useful, */ |
| 14 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 15 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 16 |
/* GNU Lesser General Public License for more details. */ |
| 17 |
/* */ |
| 18 |
/* See the GNU Lesser General Public License version 2.1 */ |
| 19 |
/* for more details (enclosed in the file licenses/LGPLv2.1). */ |
| 20 |
/* */ |
| 21 |
/**************************************************************************/ |
| 22 |
|
| 23 |
#ifndef __FC_SYS_WAIT_H__ |
| 24 |
#define __FC_SYS_WAIT_H__ |
| 25 |
#include "../features.h" |
| 26 |
__PUSH_FC_STDLIB |
| 27 |
__BEGIN_DECLS |
| 28 |
|
| 29 |
// The values for the constants/macros below are based on the glibc on |
| 30 |
// an x86 Linux, declared in the order given by POSIX.1-2008. |
| 31 |
|
| 32 |
#define WNOHANG 1 |
| 33 |
#define WCONTINUED 8 |
| 34 |
#define WUNTRACED 2 |
| 35 |
|
| 36 |
#define WEXITSTATUS(status) (((status) & 0xff00) >> 8) |
| 37 |
#define WIFCONTINUED(status) ((status) == 0xffff) |
| 38 |
#define WIFEXITED(status) (((status) & 0x7f) == 0) |
| 39 |
#define WIFSIGNALED(status) (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) |
| 40 |
#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) |
| 41 |
#define WSTOPSIG(status) WEXITSTATUS(status) |
| 42 |
#define WTERMSIG(status) ((status) & 0x7f) |
| 43 |
|
| 44 |
#define WEXITED 4 |
| 45 |
#define WNOWAIT 0x01000000 |
| 46 |
#define WSTOPPED 2 |
| 47 |
|
| 48 |
// Non-POSIX |
| 49 |
#define WCOREDUMP(status) ((status) & 0x80) |
| 50 |
|
| 51 |
#include "../__fc_define_id_t.h" |
| 52 |
#include "../__fc_define_pid_t.h" |
| 53 |
#include "../__fc_define_uid_and_gid.h" |
| 54 |
#include "../signal.h" |
| 55 |
|
| 56 |
# ifndef __ENUM_IDTYPE_T |
| 57 |
# define __ENUM_IDTYPE_T 1 |
| 58 |
typedef enum __FC_IDTYPE_T { P_ALL, P_PID, P_PGID } idtype_t; |
| 59 |
#endif |
| 60 |
|
| 61 |
/*@ //missing: assigns \result \from 'child processes' |
| 62 |
//missing: terminates 'depending on child processes' |
| 63 |
//missing: may set errno to ECHILD or EINTR |
| 64 |
assigns \result \from \nothing; |
| 65 |
assigns *stat_loc \from \nothing; |
| 66 |
ensures result_ok_or_error: \result == -1 || \result >= 0; |
| 67 |
ensures initialization:stat_loc_init_on_success: |
| 68 |
\result >= 0 && stat_loc != \null ==> \initialized(stat_loc); |
| 69 |
behavior stat_loc_null: |
| 70 |
assumes stat_loc_null: stat_loc == \null; |
| 71 |
assigns \result \from \nothing; |
| 72 |
behavior stat_loc_non_null: |
| 73 |
assumes stat_loc_non_null: stat_loc != \null; |
| 74 |
requires valid_stat_loc: \valid(stat_loc); |
| 75 |
//missing: assigns *stat_loc \from 'child processes' |
| 76 |
*/ |
| 77 |
extern pid_t wait(int *stat_loc); |
| 78 |
|
| 79 |
extern int waitid(idtype_t idt, id_t id, siginfo_t * sig, int options); |
| 80 |
|
| 81 |
|
| 82 |
/*@ //missing: assigns \result \from 'child processes' |
| 83 |
//missing: terminates 'depending on child processes' |
| 84 |
//missing: may set errno to ECHILD, EINTR or EINVAL |
| 85 |
assigns \result \from indirect:options; |
| 86 |
assigns *stat_loc \from indirect:options; |
| 87 |
ensures result_ok_or_error: \result == -1 || \result >= 0; |
| 88 |
ensures initialization:stat_loc_init_on_success: |
| 89 |
\result >= 0 && stat_loc != \null ==> \initialized(stat_loc); |
| 90 |
behavior stat_loc_null: |
| 91 |
assumes stat_loc_null: stat_loc == \null; |
| 92 |
assigns \result \from \nothing; |
| 93 |
behavior stat_loc_non_null: |
| 94 |
assumes stat_loc_non_null: stat_loc != \null; |
| 95 |
requires valid_stat_loc: \valid(stat_loc); |
| 96 |
//missing: assigns *stat_loc \from 'child processes' |
| 97 |
*/ |
| 98 |
extern pid_t waitpid(pid_t pid, int *stat_loc, int options); |
| 99 |
|
| 100 |
#include "resource.h" |
| 101 |
// non-POSIX |
| 102 |
extern pid_t wait3(int *, int, struct rusage *); |
| 103 |
|
| 104 |
|
| 105 |
__END_DECLS |
| 106 |
__POP_FC_STDLIB |
| 107 |
#endif |