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.

55 lines
1.1 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
  2. * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
  3. * © 2007 Premysl Hruby <dfenze at gmail dot com>
  4. * See LICENSE file for license details. */
  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. /* extern */
  12. void *
  13. emallocz(unsigned int size) {
  14. void *res = calloc(1, size);
  15. if(!res)
  16. eprint("fatal: could not malloc() %u bytes\n", size);
  17. return res;
  18. }
  19. void
  20. eprint(const char *errstr, ...) {
  21. va_list ap;
  22. va_start(ap, errstr);
  23. vfprintf(stderr, errstr, ap);
  24. va_end(ap);
  25. exit(EXIT_FAILURE);
  26. }
  27. void
  28. spawn(const char *arg) {
  29. static char *shell = NULL;
  30. if(!shell && !(shell = getenv("SHELL")))
  31. shell = "/bin/sh";
  32. if(!arg)
  33. return;
  34. /* The double-fork construct avoids zombie processes and keeps the code
  35. * clean from stupid signal handlers. */
  36. if(fork() == 0) {
  37. if(fork() == 0) {
  38. if(dpy)
  39. close(ConnectionNumber(dpy));
  40. setsid();
  41. execl(shell, shell, "-c", arg, (char *)NULL);
  42. fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
  43. perror(" failed");
  44. }
  45. exit(0);
  46. }
  47. wait(0);
  48. }