Configuration of dwm for Mac Computers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
932 B

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include "dwm.h"
  6. #include <stdarg.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <sys/wait.h>
  10. #include <unistd.h>
  11. /* static */
  12. static void
  13. bad_malloc(unsigned int size)
  14. {
  15. eprint("fatal: could not malloc() %u bytes\n", size);
  16. }
  17. /* extern */
  18. void *
  19. emallocz(unsigned int size)
  20. {
  21. void *res = calloc(1, size);
  22. if(!res)
  23. bad_malloc(size);
  24. return res;
  25. }
  26. void
  27. eprint(const char *errstr, ...)
  28. {
  29. va_list ap;
  30. va_start(ap, errstr);
  31. vfprintf(stderr, errstr, ap);
  32. va_end(ap);
  33. exit(EXIT_FAILURE);
  34. }
  35. void
  36. spawn(Arg *arg)
  37. {
  38. char **argv = (char **)arg->argv;
  39. if(!argv || !argv[0])
  40. return;
  41. if(fork() == 0) {
  42. if(fork() == 0) {
  43. if(dpy)
  44. close(ConnectionNumber(dpy));
  45. setsid();
  46. execvp(argv[0], argv);
  47. fprintf(stderr, "dwm: execvp %s", argv[0]);
  48. perror(" failed");
  49. }
  50. exit(0);
  51. }
  52. wait(0);
  53. }