netutil.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Network utilities for the Midnight Commander Virtual File System.
  3. Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2011
  4. The Free Software Foundation, Inc.
  5. This file is part of the Midnight Commander.
  6. The Midnight Commander is free software: you can redistribute it
  7. and/or modify it under the terms of the GNU General Public License as
  8. published by the Free Software Foundation, either version 3 of the License,
  9. or (at your option) any later version.
  10. The Midnight Commander is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file
  19. * \brief Source: Virtual File System: Network utilities
  20. */
  21. #include <config.h>
  22. #include <stdlib.h>
  23. #include <signal.h>
  24. #include "lib/global.h"
  25. #include "netutil.h"
  26. /*** global variables ****************************************************************************/
  27. volatile sig_atomic_t got_sigpipe = 0;
  28. /*** file scope macro definitions ****************************************************************/
  29. /*** file scope type declarations ****************************************************************/
  30. /*** file scope variables ************************************************************************/
  31. /*** file scope functions ************************************************************************/
  32. /* --------------------------------------------------------------------------------------------- */
  33. static void
  34. sig_pipe (int unused)
  35. {
  36. (void) unused;
  37. got_sigpipe = 1;
  38. }
  39. /* --------------------------------------------------------------------------------------------- */
  40. /*** public functions ****************************************************************************/
  41. /* --------------------------------------------------------------------------------------------- */
  42. void
  43. tcp_init (void)
  44. {
  45. static gboolean initialized = FALSE;
  46. struct sigaction sa;
  47. if (initialized)
  48. return;
  49. got_sigpipe = 0;
  50. sa.sa_handler = sig_pipe;
  51. sa.sa_flags = 0;
  52. sigemptyset (&sa.sa_mask);
  53. sigaction (SIGPIPE, &sa, NULL);
  54. initialized = TRUE;
  55. }
  56. /* --------------------------------------------------------------------------------------------- */