1 /* ################################################################### */
2 /* Copyright 2015, Pierre Gentile (p.gen.progs@gmail.com) */
4 /* This Source Code Form is subject to the terms of the Mozilla Public */
5 /* License, v. 2.0. If a copy of the MPL was not distributed with this */
6 /* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 /* ################################################################### */
9 /* ************************************ */
10 /* Some wrappers to manage EINTR errors */
11 /* ************************************ */
23 fopen_safe(const char * restrict stream
, const char * restrict mode
)
27 while ((file
= fopen(stream
, mode
)) == NULL
&& errno
== EINTR
)
34 tcsetattr_safe(int fildes
,
36 const struct termios
*termios_p
)
40 while ((res
= tcsetattr(fildes
, optional_actions
, termios_p
)) == -1
48 fputc_safe(int c
, FILE *stream
)
52 while ((res
= fputc(c
, stream
)) == -1 && errno
== EINTR
)
59 fputs_safe(const char * restrict s
, FILE * restrict stream
)
63 while ((res
= fputs(s
, stream
)) == -1 && errno
== EINTR
)