History

race condition (wctl access) with riow - don't fail if wctl fails to open

Sigrid Solveig Haflínudóttir committed 4 years ago

Commit 595e1941 parent a45b2a41 file · +4 −3Browse files

Unified · Split

bar.c+4−3
@@ -13,7 +13,7 @@ enum { · 12 unmodified lines
13 Off = 3,13 Off = 3,
14};14};
15 15
16static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;16static int wctl = -1, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;
17static char sep[16], bats[16], *aux;17static char sep[16], bats[16], *aux;
18static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64];18static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64];
19static int itemw[64], nitems;19static int itemw[64], nitems;
@@ -68,6 +68,9 @@ place(void) · 48 unmodified lines
68 char t[64];68 char t[64];
69 static int ow, oh;69 static int ow, oh;
70 70
71 if(wctl < 0 && (wctl = open("/dev/wctl", OWRITE)) < 0)
72 return;
73
71 fprint(wctl, bottom ? "bottom" : "top");74 fprint(wctl, bottom ? "bottom" : "top");
72 w = Dx(display->image->r);75 w = Dx(display->image->r);
73 h = Dy(display->image->r);76 h = Dy(display->image->r);
@@ -298,8 +301,6 @@ threadmain(int argc, char **argv) · 224 unmodified lines
298 Bterm(b);301 Bterm(b);
299 }302 }
300 303
301 if((wctl = open("/dev/wctl", ORDWR)) < 0)
302 sysfatal("%r");
303 bat = open("/mnt/pm/battery", OREAD);304 bat = open("/mnt/pm/battery", OREAD);
304 if(initdraw(nil, nil, "bar") < 0)305 if(initdraw(nil, nil, "bar") < 0)
305 sysfatal("initdraw: %r");306 sysfatal("initdraw: %r");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t