6 * Absent other hints, it works reasonably well to use
7 * the X11 display name as the name space identifier.
8 * This is how sam's B has worked since the early days.
9 * Since most programs using name spaces are also using X,
10 * this still seems reasonable. Terminal-only sessions
20 if((disp = getenv("DISPLAY")) == nil){
21 werrstr("$DISPLAY not set");
25 /* canonicalize: xxx:0.0 => xxx:0 */
26 p = strrchr(disp, ':');
29 while(isdigit((uchar)*p))
31 if(strcmp(p, ".0") == 0)
35 p = smprint("/tmp/ns.%s.%s", getuser(), disp);
38 werrstr("out of memory");
41 if((fd=create(p, OREAD, DMDIR|0700)) >= 0){
45 if((d = dirstat(p)) == nil){
47 werrstr("stat %s: %r", p);
51 if((d->mode&0777) != 0700 || strcmp(d->uid, getuser()) != 0){
52 werrstr("bad name space dir %s", p);
66 ns = getenv("NAMESPACE");
70 werrstr("$NAMESPACE not set, %r");