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
1313 Off = 3,
1414 };
1515
16−static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;
16+static int wctl = -1, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;
1717 static char sep[16], bats[16], *aux;
1818 static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64];
1919 static int itemw[64], nitems;
@@ -68,6 +68,9 @@ place(void) · 48 unmodified lines
6868 char t[64];
6969 static int ow, oh;
7070
71+ if(wctl < 0 && (wctl = open("/dev/wctl", OWRITE)) < 0)
72+ return;
73+
7174 fprint(wctl, bottom ? "bottom" : "top");
7275 w = Dx(display->image->r);
7376 h = Dy(display->image->r);
@@ -298,8 +301,6 @@ threadmain(int argc, char **argv) · 224 unmodified lines
298301 Bterm(b);
299302 }
300303
301− if((wctl = open("/dev/wctl", ORDWR)) < 0)
302− sysfatal("%r");
303304 bat = open("/mnt/pm/battery", OREAD);
304305 if(initdraw(nil, nil, "bar") < 0)
305306 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