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.

63 lines
1.1 KiB

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. /* 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. erealloc(void *ptr, unsigned int size) {
  29. void *res = realloc(ptr, size);
  30. if(!res)
  31. eprint("fatal: could not malloc() %u bytes\n", size);
  32. return res;
  33. }
  34. void
  35. spawn(Arg *arg) {
  36. static char *shell = NULL;
  37. if(!shell && !(shell = getenv("SHELL")))
  38. shell = "/bin/sh";
  39. if(!arg->cmd)
  40. return;
  41. /* the double-fork construct avoids zombie processes */
  42. if(fork() == 0) {
  43. if(fork() == 0) {
  44. if(dpy)
  45. close(ConnectionNumber(dpy));
  46. setsid();
  47. execl(shell, shell, "-c", arg->cmd, (char *)NULL);
  48. fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
  49. perror(" failed");
  50. }
  51. exit(0);
  52. }
  53. wait(0);
  54. }