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.

54 lines
1.0 KiB

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