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.

56 lines
1.2 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. * © 2007 Szabolcs Nagy <nszabolcs at gmail dot com>
  5. * See LICENSE file for license details. */
  6. #include "dwm.h"
  7. #include <stdarg.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <sys/wait.h>
  11. #include <unistd.h>
  12. /* extern */
  13. void *
  14. emallocz(unsigned int size) {
  15. void *res = calloc(1, size);
  16. if(!res)
  17. eprint("fatal: could not malloc() %u bytes\n", size);
  18. return res;
  19. }
  20. void
  21. eprint(const char *errstr, ...) {
  22. va_list ap;
  23. va_start(ap, errstr);
  24. vfprintf(stderr, errstr, ap);
  25. va_end(ap);
  26. exit(EXIT_FAILURE);
  27. }
  28. void
  29. spawn(const char *arg) {
  30. static char *shell = NULL;
  31. if(!shell && !(shell = getenv("SHELL")))
  32. shell = "/bin/sh";
  33. if(!arg)
  34. return;
  35. /* The double-fork construct avoids zombie processes and keeps the code
  36. * clean from stupid signal handlers. */
  37. if(fork() == 0) {
  38. if(fork() == 0) {
  39. if(dpy)
  40. close(ConnectionNumber(dpy));
  41. setsid();
  42. execl(shell, shell, "-c", arg, (char *)NULL);
  43. fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
  44. perror(" failed");
  45. }
  46. exit(0);
  47. }
  48. wait(0);
  49. }