-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
142 changed files
with
4,662 additions
and
2,918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
0.0.1 to 0.0.2 | ||
=== | ||
* `luastatus.spawn`, `luastatus.rc` and `luastatus.dollar` functions have been removed. | ||
Use `os.execute` and/or `io.popen` instead — and please don’t forget to properly escape the arguments: | ||
````lua | ||
function shell_escape(s) | ||
return "'" .. s:gsub("'", "'\\''") .. "'" | ||
end | ||
```` | ||
|
||
* `pipe` plugin has been removed. Use the `timer` plugin and `io.open` instead: | ||
````lua | ||
wdiget = { | ||
plugin = 'timer', | ||
cb = function() | ||
for line in assert(io.open('your command', 'r')):lines() do | ||
-- blah-blah-blah | ||
end | ||
end, | ||
} | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Thread-safety | ||
=== | ||
Each non-thread-safe thing must be synchronized with other entities by means of | ||
the `map_get` function (see `DOCS/design/map_get.md`). | ||
|
||
Misc | ||
=== | ||
Your plugin or barlib must not modify environment variables (this includes | ||
`unsetenv()`, `setenv()`, `putenv()`, and modifying `environ`). | ||
|
||
Your plugin or barlib can install signal handlers, but: | ||
|
||
1. this must be done with `sigaction()`, and `sa_mask` field of | ||
`struct sigaction` must include `SA_RESTART`. | ||
|
||
2. the handler must not be `SIG_IGN`, as it gets inherited by child | ||
processes; | ||
|
||
3. you must add a taint with the name of the signal, e.g. `"SIGUSR1"`. | ||
|
||
Your plugin or barlib can call `pthread_sigmask()` (and, consequently, | ||
`pselect()`). | ||
|
||
Writing a plugin | ||
=== | ||
Copy `include/plugin_data.h`, `include/plugin_data_v1.h`, `include/plugin_v1.h` and `include/common.h`; | ||
include `include/plugin_v1.h` and start reading `include/plugin_data.h`. | ||
|
||
Then, declare a global `const LuastatusIfacePlugin luastatus_iface_plugin_v1` variable. | ||
|
||
Writing a barlib | ||
=== | ||
Copy `include/barlib_data.h`, `include/barlib_data_v1.h`, `include/barlib_v1.h` and `include/common.h`; | ||
include `include/barlib_v1.h` and start reading `include/barlib_data.h`. | ||
|
||
Then, declare a global `const LuastatusIfaceBarlib luastatus_iface_barlib_v1` variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The main problem is that all the stdio functions may, according to POSIX, fail with `EINTR`, and there is no way to restart some of them, e.g. `fprintf`. | ||
|
||
Our solution is to ensure that `SA_RESTART` is set for all the signals that could be raised (without terminating the program). | ||
|
||
See also: http://man7.org/linux/man-pages/man7/signal.7.html, section "Interruption of system calls and library functions by signal handlers". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf | ||
|
||
Subclause 7.1.4 Use of library functions, point 1: | ||
|
||
> Each of the following statements applies unless explicitly stated otherwise in the | ||
> detailed descriptions that follow: If an argument to a function has an invalid value (such | ||
> as a value outside the domain of the function, or a pointer outside the address space of | ||
> the program, or a null pointer, or a pointer to non-modifiable storage when the | ||
> corresponding parameter is not const-qualified) or a type (after promotion) not expected | ||
> by a function with variable number of arguments, the behavior is undefined. If a function | ||
> argument is described as being an array, the pointer actually passed to the function shall | ||
> have a value such that all address computations and accesses to objects (that would be | ||
> valid if the pointer did point to the first element of such an array) are in fact valid. | ||
It’s not OK to call any function defined in `<string.h>` with a pointer that can’t be dereferenced: | ||
|
||
Subclause 7.21.1 String handling conventions, point 2: | ||
|
||
> Where an argument declared as `size_t n` specifies the length of the array for a function, `n` | ||
> can have the value zero on a call to that function. Unless explicitly stated otherwise in | ||
> the description of a particular function in this subclause, pointer arguments on such a | ||
> call shall still have valid values, as described in 7.1.4. On such a call, a function | ||
> that locates a character finds no occurrence, a function that compares two character | ||
> sequences returns zero, and a function that copies characters copies zero characters. | ||
It’s not OK to call `qsort`/`bsearch` with a pointer that can’t be dereferenced: | ||
|
||
Subclause 7.20.5 Searching and sorting utilites, point 1: | ||
|
||
> These utilities make use of a comparison function to search or sort arrays of unspecified | ||
> type. Where an argument declared as `size_t nmemb` specifies the length of the array for a | ||
> function, `nmemb` can have the value zero on a call to that function; the comparison function | ||
> is not called, a search finds no matching element, and sorting performs no rearrangement. | ||
> Pointer arguments on such a call shall still have valid values, as described in 7.1.4. | ||
However, it’s OK to call `snprintf`/`vsnprintf` with a pointer that can’t be dereferenced, as long as `n` is zero: | ||
|
||
Subclause 7.19.6.5 The `snprintf` function, point 2: | ||
|
||
> The `snprintf` function is equivalent to `fprintf`, except that the output is written into an | ||
> array (specified by argument `s`) rather than to a stream. If `n` is zero, nothing is written, and | ||
> `s` may be a null pointer. Otherwise, output characters beyond the `n-1`st are discarded rather | ||
> than being written to the array, and a null character is written at the end of the characters | ||
> actually written into the array. If copying takes place between objects that overlap, the behavior | ||
> is undefined. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
luastatus provides the following function to barlibs and plugins: | ||
|
||
````c | ||
void ** (*map_get)(void *userdata, const char *key); | ||
```` | ||
|
||
This function is **not** thread-safe and should only be used in the `init` function. | ||
|
||
luastatus maintains a global mapping from zero-terminated strings to pointers (`void *`). | ||
`map_get` returns a pointer to the pointer corresponding to the given key; if a map entry with the given key does not exist, it creates one with a null pointer value. | ||
|
||
You can read and/or write from/to this pointer-to-pointer; it is guaranteed to be persistent across other calls to `map_get` and other functions. | ||
However, note that it is **not** `void *volatile *`, so you should not write to it from functions other than `init`. | ||
|
||
Its intended use is for synchronization. |
Oops, something went wrong.