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.

59 lines
944 B

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 <stdarg.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <sys/types.h>
  9. #include <sys/wait.h>
  10. #include <unistd.h>
  11. #include "dwm.h"
  12. void
  13. eprint(const char *errstr, ...) {
  14. va_list ap;
  15. va_start(ap, errstr);
  16. vfprintf(stderr, errstr, ap);
  17. va_end(ap);
  18. exit(1);
  19. }
  20. static void
  21. bad_malloc(unsigned int size)
  22. {
  23. fprintf(stderr, "fatal: could not malloc() %d bytes\n",
  24. (int) size);
  25. exit(1);
  26. }
  27. void *
  28. emallocz(unsigned int size)
  29. {
  30. void *res = calloc(1, size);
  31. if(!res)
  32. bad_malloc(size);
  33. return res;
  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. }