MCPcopy Create free account
hub / github.com/coreutils/coreutils / strip

Function strip

src/install.c:490–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488 it portable would be very difficult. Not worth the effort. */
489
490static bool
491strip (char const *name)
492{
493 posix_spawnattr_t attr;
494 posix_spawnattr_t *attrp = NULL;
495
496 /* Try to use vfork for systems where it matters. */
497 if (posix_spawnattr_init (&attr) == 0)
498 {
499 if (posix_spawnattr_setflags (&attr, POSIX_SPAWN_USEVFORK) == 0)
500 attrp = &attr;
501 else
502 posix_spawnattr_destroy (&attr);
503 }
504
505 /* Construct the arguments to 'strip'. */
506 char *concat_name = NULL;
507 char const *safe_name = name;
508 if (name && *name == '-')
509 safe_name = concat_name = file_name_concat (".", name, NULL);
510 char const *const argv[] = { strip_program, safe_name, NULL };
511
512 /* Run 'strip'. */
513 pid_t pid;
514 int result = posix_spawnp (&pid, strip_program, NULL, attrp,
515 (char * const *) argv, environ);
516
517 bool ok = false;
518 if (result != 0)
519 {
520 error (0, result,
521 streq (strip_program, "strip")
522 ? _("cannot run %s")
523 : _("cannot run strip program %s"),
524 quoteaf (strip_program));
525 }
526 else
527 {
528 /* Wait for 'strip' to complete, and emit a warning message on failure */
529 int status;
530 if (waitpid (pid, &status, 0) < 0)
531 error (0, errno, _("waiting for strip"));
532 else if (! WIFEXITED (status) || WEXITSTATUS (status))
533 error (0, 0, _("strip process terminated abnormally"));
534 else
535 ok = true;
536 }
537
538 free (concat_name);
539 if (attrp)
540 posix_spawnattr_destroy (attrp);
541
542 return ok;
543}
544
545/* Initialize the user and group ownership of the files to install. */
546

Callers 1

install_file_in_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected