OpenCoverage

nohup.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/nohup.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8static struct option const long_options[] =-
9{-
10 {-
11 ((void *)0)-
12 , 0, -
13 ((void *)0)-
14 , 0}-
15};-
16-
17-
18enum-
19 {-
20-
21 POSIX_NOHUP_FAILURE = 127-
22 };-
23-
24void-
25usage (int status)-
26{-
27 if (status !=
status != 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • nohup
FALSEevaluated 3 times by 1 test
Evaluated by:
  • nohup
3-5
28 0
status != 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • nohup
FALSEevaluated 3 times by 1 test
Evaluated by:
  • nohup
3-5
29 )-
30 do { fprintf (-
31 stderr-
32 , -
33 dcgettext (((void *)0), -
34 "Try '%s --help' for more information.\n"-
35 , 5)-
36 , program_name); }
executed 5 times by 1 test: end of block
Executed by:
  • nohup
while (0);
5
37 else-
38 {-
39 printf (-
40 dcgettext (((void *)0), -
41 "Usage: %s COMMAND [ARG]...\n or: %s OPTION\n"-
42 , 5)-
43-
44-
45 -
46 ,-
47 program_name, program_name);-
48-
49 fputs_unlocked (-
50 dcgettext (((void *)0), -
51 "Run COMMAND, ignoring hangup signals.\n\n"-
52 , 5)-
53 ,-
54 stdout-
55 )-
56-
57-
58 ;-
59 fputs_unlocked (-
60 dcgettext (((void *)0), -
61 " --help display this help and exit\n"-
62 , 5)-
63 ,-
64 stdout-
65 );-
66 fputs_unlocked (-
67 dcgettext (((void *)0), -
68 " --version output version information and exit\n"-
69 , 5)-
70 ,-
71 stdout-
72 );-
73 printf (-
74 dcgettext (((void *)0), -
75 "\nIf standard input is a terminal, redirect it from an unreadable file.\nIf standard output is a terminal, append output to 'nohup.out' if possible,\n'$HOME/nohup.out' otherwise.\nIf standard error is a terminal, redirect it to standard output.\nTo save output to FILE, use '%s COMMAND > FILE'.\n"-
76 , 5)-
77-
78-
79-
80-
81 -
82 ,-
83 program_name);-
84 printf (-
85 dcgettext (((void *)0), -
86 "\n" "NOTE: your shell may have its own version of %s, which usually supersedes\n" "the version described here. Please refer to your shell's documentation\n" "for details about the options it supports.\n"-
87 , 5)-
88 , "nohup");-
89 emit_ancillary_info ("nohup");-
90 }
executed 3 times by 1 test: end of block
Executed by:
  • nohup
3
91 exit (status);
executed 8 times by 1 test: exit (status);
Executed by:
  • nohup
8
92}-
93-
94int-
95main (int argc, char **argv)-
96{-
97 int out_fd = -
98 1-
99 ;-
100 int saved_stderr_fd = -
101 2-
102 ;-
103 -
104 _Bool -
105 ignoring_input;-
106 -
107 _Bool -
108 redirecting_stdout;-
109 -
110 _Bool -
111 stdout_is_closed;-
112 -
113 _Bool -
114 redirecting_stderr;-
115 int exit_internal_failure;-
116-
117 ;-
118 set_program_name (argv[0]);-
119 setlocale (-
120 6-
121 , "");-
122 bindtextdomain ("coreutils", "/usr/local/share/locale");-
123 textdomain ("coreutils");-
124-
125-
126-
127-
128-
129 exit_internal_failure = (getenv ("POSIXLY_CORRECT")
getenv ("POSIXLY_CORRECT")Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • nohup
FALSEevaluated 14 times by 1 test
Evaluated by:
  • nohup
1-14
130 ? POSIX_NOHUP_FAILURE : EXIT_CANCELED);-
131 initialize_exit_failure (exit_internal_failure);-
132 atexit (close_stdout);-
133-
134 parse_long_options (argc, argv, "nohup", "GNU coreutils", Version,-
135 usage, ("Jim Meyering"), (char const *) -
136 ((void *)0)-
137 );-
138 if (getopt_long (argc, argv, "+", long_options,
getopt_long (a...d *)0) ) != -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • nohup
FALSEevaluated 4 times by 1 test
Evaluated by:
  • nohup
3-4
139 ((void *)0)
getopt_long (a...d *)0) ) != -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • nohup
FALSEevaluated 4 times by 1 test
Evaluated by:
  • nohup
3-4
140 ) != -1
getopt_long (a...d *)0) ) != -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • nohup
FALSEevaluated 4 times by 1 test
Evaluated by:
  • nohup
)
3-4
141 usage (exit_internal_failure);
executed 3 times by 1 test: usage (exit_internal_failure);
Executed by:
  • nohup
3
142-
143 if (argc <= optind
argc <= optindDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • nohup
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
)
2
144 {-
145 error (0, 0, -
146 dcgettext (((void *)0), -
147 "missing operand"-
148 , 5)-
149 );-
150 usage (exit_internal_failure);-
151 }
never executed: end of block
0
152-
153 ignoring_input = isatty (-
154 0-
155 );-
156 redirecting_stdout = isatty (-
157 1-
158 );-
159 stdout_is_closed = (!redirecting_stdout
!redirecting_stdoutDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • nohup
FALSEnever evaluated
&&
0-2
160 (*
(*__errno_location ()) == 9Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
__errno_location ())
(*__errno_location ()) == 9Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
0-2
161 ==
(*__errno_location ()) == 9Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
0-2
162 9
(*__errno_location ()) == 9Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
0-2
163 );-
164 redirecting_stderr = isatty (-
165 2-
166 );-
167-
168-
169-
170-
171 if (ignoring_input
ignoring_inputDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
)
0-2
172 {-
173 if (fd_reopen (
fd_reopen ( 0 ...", 01 , 0) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
174 0
fd_reopen ( 0 ...", 01 , 0) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
175 , "/dev/null",
fd_reopen ( 0 ...", 01 , 0) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
176 01
fd_reopen ( 0 ...", 01 , 0) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
177 , 0) < 0
fd_reopen ( 0 ...", 01 , 0) < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
178 error (exit_internal_failure,
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
179 (*__errno_location ())
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
180 ,
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
181
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
182 dcgettext (((void *)0),
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
183 "failed to render standard input unusable"
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
184 , 5)
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
185 );
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to render standard input unusable" , 5) );
0
186 if (!redirecting_stdout
!redirecting_stdoutDescription
TRUEnever evaluated
FALSEnever evaluated
&& !redirecting_stderr
!redirecting_stderrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
187 error (0, 0,
never executed: error (0, 0, dcgettext (((void *)0), "ignoring input" , 5) );
0
188 dcgettext (((void *)0),
never executed: error (0, 0, dcgettext (((void *)0), "ignoring input" , 5) );
0
189 "ignoring input"
never executed: error (0, 0, dcgettext (((void *)0), "ignoring input" , 5) );
0
190 , 5)
never executed: error (0, 0, dcgettext (((void *)0), "ignoring input" , 5) );
0
191 );
never executed: error (0, 0, dcgettext (((void *)0), "ignoring input" , 5) );
0
192 }
never executed: end of block
0
193-
194-
195-
196-
197-
198 if (redirecting_stdout
redirecting_stdoutDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
|| (redirecting_stderr
redirecting_stderrDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
&& stdout_is_closed
stdout_is_closedDescription
TRUEnever evaluated
FALSEnever evaluated
))
0-2
199 {-
200 char *in_home = -
201 ((void *)0)-
202 ;-
203 char const *file = "nohup.out";-
204 int flags = -
205 0100 -
206 | -
207 01 -
208 | -
209 02000-
210 ;-
211 mode_t mode = -
212 0400 -
213 | -
214 0200-
215 ;-
216 mode_t umask_value = umask (~mode);-
217 out_fd = (redirecting_stdout
redirecting_stdoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
218 ? fd_reopen (-
219 1-
220 , file, flags, mode)-
221 : open (file, flags, mode));-
222-
223 if (out_fd < 0
out_fd < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
224 {-
225 int saved_errno = -
226 (*__errno_location ())-
227 ;-
228 char const *home = getenv ("HOME");-
229 if (home
homeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
230 {-
231 in_home = file_name_concat (home, file, -
232 ((void *)0)-
233 );-
234 out_fd = (redirecting_stdout
redirecting_stdoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
235 ? fd_reopen (-
236 1-
237 , in_home, flags, mode)-
238 : open (in_home, flags, mode));-
239 }
never executed: end of block
0
240 if (out_fd < 0
out_fd < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
241 {-
242 int saved_errno2 = -
243 (*__errno_location ())-
244 ;-
245 error (0, saved_errno, -
246 dcgettext (((void *)0), -
247 "failed to open %s"-
248 , 5)-
249 , quotearg_style (shell_escape_always_quoting_style, file));-
250 if (in_home
in_homeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
251 error (0, saved_errno2,
never executed: error (0, saved_errno2, dcgettext (((void *)0), "failed to open %s" , 5) , quotearg_style (shell_escape_always_quoting_style, in_home));
0
252 dcgettext (((void *)0),
never executed: error (0, saved_errno2, dcgettext (((void *)0), "failed to open %s" , 5) , quotearg_style (shell_escape_always_quoting_style, in_home));
0
253 "failed to open %s"
never executed: error (0, saved_errno2, dcgettext (((void *)0), "failed to open %s" , 5) , quotearg_style (shell_escape_always_quoting_style, in_home));
0
254 , 5)
never executed: error (0, saved_errno2, dcgettext (((void *)0), "failed to open %s" , 5) , quotearg_style (shell_escape_always_quoting_style, in_home));
0
255 ,
never executed: error (0, saved_errno2, dcgettext (((void *)0), "failed to open %s" , 5) , quotearg_style (shell_escape_always_quoting_style, in_home));
0
256 quotearg_style (shell_escape_always_quoting_style, in_home));
never executed: error (0, saved_errno2, dcgettext (((void *)0), "failed to open %s" , 5) , quotearg_style (shell_escape_always_quoting_style, in_home));
0
257 return
never executed: return exit_internal_failure;
exit_internal_failure;
never executed: return exit_internal_failure;
0
258 }-
259 file = in_home;-
260 }
never executed: end of block
0
261-
262 umask (umask_value);-
263 error (0, 0,-
264 -
265 dcgettext (((void *)0), -
266 ignoring_input ? "ignoring input and appending output to %s" : "appending output to %s"-
267 , 5)-
268-
269 -
270 ,-
271 quotearg_style (shell_escape_always_quoting_style, file));-
272 free (in_home);-
273 }
never executed: end of block
0
274-
275-
276 if (redirecting_stderr
redirecting_stderrDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
)
0-2
277 {-
278-
279-
280-
281-
282 saved_stderr_fd = -
283 rpl_fcntl -
284 (-
285 2-
286 , -
287 1030-
288 ,-
289 -
290 2 -
291 + 1);-
292-
293 if (!redirecting_stdout
!redirecting_stdoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
294 error (0, 0,
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
295
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
296 dcgettext (((void *)0),
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
297 ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout"
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
298 , 5)
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
2990
300
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
301 );
never executed: error (0, 0, dcgettext (((void *)0), ignoring_input ? "ignoring input and redirecting stderr to stdout" : "redirecting stderr to stdout" , 5) );
0
302-
303 if (dup2 (out_fd,
dup2 (out_fd, 2 ) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
304 2
dup2 (out_fd, 2 ) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
305 ) < 0
dup2 (out_fd, 2 ) < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
306 error (exit_internal_failure,
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
307 (*__errno_location ())
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
308 ,
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
309
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
310 dcgettext (((void *)0),
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
311 "failed to redirect standard error"
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
312 , 5)
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
313 );
never executed: error (exit_internal_failure, (*__errno_location ()) , dcgettext (((void *)0), "failed to redirect standard error" , 5) );
0
314-
315 if (stdout_is_closed
stdout_is_closedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
316 close (out_fd);
never executed: close (out_fd);
0
317 }
never executed: end of block
0
318-
319-
320-
321-
322-
323-
324-
325 if (ferror_unlocked (
ferror_unlocked ( stderr )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
0-2
326 stderr
ferror_unlocked ( stderr )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
0-2
327 )
ferror_unlocked ( stderr )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • nohup
)
0-2
328 return
never executed: return exit_internal_failure;
exit_internal_failure;
never executed: return exit_internal_failure;
0
329-
330 signal (-
331 1-
332 , -
333 ((__sighandler_t) 1)-
334 );-
335-
336 char **cmd = argv + optind;-
337 execvp (*cmd, cmd);-
338 int exit_status = -
339 (*
(*__errno_location ()) == 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • nohup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • nohup
__errno_location ())
(*__errno_location ()) == 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • nohup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • nohup
1
340 ==
(*__errno_location ()) == 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • nohup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • nohup
1
341 2
(*__errno_location ()) == 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • nohup
FALSEevaluated 1 time by 1 test
Evaluated by:
  • nohup
1
342 ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;-
343 int saved_errno = -
344 (*__errno_location ())-
345 ;-
346-
347-
348-
349-
350-
351-
352-
353 if (dup2 (saved_stderr_fd,
dup2 (saved_st...r_fd, 2 ) == 2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • nohup
FALSEnever evaluated
0-2
354 2
dup2 (saved_st...r_fd, 2 ) == 2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • nohup
FALSEnever evaluated
0-2
355 ) ==
dup2 (saved_st...r_fd, 2 ) == 2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • nohup
FALSEnever evaluated
0-2
356 2
dup2 (saved_st...r_fd, 2 ) == 2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • nohup
FALSEnever evaluated
0-2
357 )-
358 error (0, saved_errno,
executed 2 times by 1 test: error (0, saved_errno, dcgettext (((void *)0), "failed to run command %s" , 5) , quotearg_style (shell_escape_always_quoting_style, *cmd));
Executed by:
  • nohup
2
359 dcgettext (((void *)0),
executed 2 times by 1 test: error (0, saved_errno, dcgettext (((void *)0), "failed to run command %s" , 5) , quotearg_style (shell_escape_always_quoting_style, *cmd));
Executed by:
  • nohup
2
360 "failed to run command %s"
executed 2 times by 1 test: error (0, saved_errno, dcgettext (((void *)0), "failed to run command %s" , 5) , quotearg_style (shell_escape_always_quoting_style, *cmd));
Executed by:
  • nohup
2
361 , 5)
executed 2 times by 1 test: error (0, saved_errno, dcgettext (((void *)0), "failed to run command %s" , 5) , quotearg_style (shell_escape_always_quoting_style, *cmd));
Executed by:
  • nohup
2
362 , quotearg_style (shell_escape_always_quoting_style, *cmd));
executed 2 times by 1 test: error (0, saved_errno, dcgettext (((void *)0), "failed to run command %s" , 5) , quotearg_style (shell_escape_always_quoting_style, *cmd));
Executed by:
  • nohup
2
363-
364 return
executed 2 times by 1 test: return exit_status;
Executed by:
  • nohup
exit_status;
executed 2 times by 1 test: return exit_status;
Executed by:
  • nohup
2
365}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2