newwindow.c 424 B

123456789101112131415161718192021222324252627
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. /* Connect us to new window, if possible */
  5. int
  6. newwindow(char *str)
  7. {
  8. int fd;
  9. char *wsys;
  10. char buf[256];
  11. wsys = getenv("wsys");
  12. if(wsys == nil)
  13. return -1;
  14. fd = open(wsys, ORDWR);
  15. free(wsys);
  16. if(fd < 0)
  17. return -1;
  18. rfork(RFNAMEG);
  19. if(str)
  20. snprint(buf, sizeof buf, "new %s", str);
  21. else
  22. strcpy(buf, "new");
  23. return mount(fd, -1, "/dev", MBEFORE, buf);
  24. }