mkfifo.c 790 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * mkfifo implementation for busybox
  4. *
  5. * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  8. */
  9. /* BB_AUDIT SUSv3 compliant */
  10. /* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
  11. #include <stdlib.h>
  12. #include <unistd.h>
  13. #include <sys/types.h>
  14. #include "busybox.h"
  15. #include "libcoreutils/coreutils.h"
  16. int mkfifo_main(int argc, char **argv)
  17. {
  18. mode_t mode;
  19. int retval = EXIT_SUCCESS;
  20. mode = getopt_mk_fifo_nod(argc, argv);
  21. if (!*(argv += optind)) {
  22. bb_show_usage();
  23. }
  24. do {
  25. if (mkfifo(*argv, mode) < 0) {
  26. bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
  27. retval = EXIT_FAILURE;
  28. }
  29. } while (*++argv);
  30. return retval;
  31. }