mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
sd-event: make return code of sd_event_get_exit_code() optional
This commit is contained in:
parent
4a5aa6842d
commit
7253eaa0fb
@ -65,9 +65,11 @@
|
|||||||
the exit code stored in the event loop object is updated, but
|
the exit code stored in the event loop object is updated, but
|
||||||
otherwise no further operation is executed.</para>
|
otherwise no further operation is executed.</para>
|
||||||
|
|
||||||
<para><function>sd_event_get_exit_code()</function> may be used to
|
<para><function>sd_event_get_exit_code()</function> may be used to query the exit code passed to an
|
||||||
query the exit code passed into
|
earlier call of <function>sd_event_exit()</function>. The return parameter <parameter>code</parameter>
|
||||||
<function>sd_event_exit()</function> earlier.</para>
|
may be set to <constant>NULL</constant>, in order to simply check if <function>sd_event_exit()</function>
|
||||||
|
has been called before (as <function>sd_event_get_exit_code()</function> fails with
|
||||||
|
<constant>-ENODATA</constant> if that's not the case, see below).</para>
|
||||||
|
|
||||||
<para>While the full positive and negative integer ranges may be used
|
<para>While the full positive and negative integer ranges may be used
|
||||||
for the exit code, care should be taken not pick exit codes that
|
for the exit code, care should be taken not pick exit codes that
|
||||||
@ -122,7 +124,8 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><constant>-ENODATA</constant></term>
|
<term><constant>-ENODATA</constant></term>
|
||||||
|
|
||||||
<listitem><para>The event loop has not been requested to exit yet.</para></listitem>
|
<listitem><para>Returned by <function>sd_event_get_exit_code()</function> in case the event loop has not
|
||||||
|
been requested to exit yet.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
@ -4915,13 +4915,13 @@ _public_ int sd_event_get_state(sd_event *e) {
|
|||||||
_public_ int sd_event_get_exit_code(sd_event *e, int *code) {
|
_public_ int sd_event_get_exit_code(sd_event *e, int *code) {
|
||||||
assert_return(e, -EINVAL);
|
assert_return(e, -EINVAL);
|
||||||
assert_return(e = event_resolve(e), -ENOPKG);
|
assert_return(e = event_resolve(e), -ENOPKG);
|
||||||
assert_return(code, -EINVAL);
|
|
||||||
assert_return(!event_origin_changed(e), -ECHILD);
|
assert_return(!event_origin_changed(e), -ECHILD);
|
||||||
|
|
||||||
if (!e->exit_requested)
|
if (!e->exit_requested)
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
|
||||||
*code = e->exit_code;
|
if (code)
|
||||||
|
*code = e->exit_code;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user