<div dir="auto">perror doesn't define exit statuses. It defines syscall return codes and libc function errno values, which usually have nothing to do with the exit code of the whole process.<div dir="auto"><br></div><div dir="auto">Aside from the convention that "non-zero = failure", you have to look at the docs of the whole program (e.g. if it's a shell script and the last thing it did was call `curl` then the exit status is defined by curl).</div><div dir="auto"><br></div><div dir="auto">I don't think system-sleep hooks are the right place to do network calls. They're run at the last possible point, right before systemd tells the kernel to suspend, but after it has informed userspace.</div><div dir="auto"><br></div><div dir="auto">Hooking into sleep.target or using dbus to listen for the "PrepareForSleep" signal might work better. Though I'm not sure how to make sure you get to process the signal before NetworkManager does the same thing.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 11, 2021, 18:05 Doug Koobs <<a href="mailto:dkoobs@dkoobs.com">dkoobs@dkoobs.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
tldr: Is there way I can use systemd to run scripts in <br>
/usr/lib/systemd/system-sleep at suspend before disabling the network?<br>
<br>
I've put a script in /usr/lib/systemd/system-sleep that makes an HTTP <br>
post to an IFTTT webhook when it's passed "pre" as $1. The script is <br>
successful if I run it manually, but when systemd runs it when I suspend <br>
the laptop, running "journalctl -b -u systemd-suspend.service" reports:<br>
<br>
     /usr/lib/systemd/system-sleep/outlet.sh failed with exit status 6.<br>
<br>
perror defines exit status 6 as: OS error code   6:  No such device or <br>
address<br>
<br>
This sounds like a network problem. If I disable networking and manually <br>
run the script, I get:<br>
<br>
     curl: (6) Could not resolve host: <a href="http://maker.ifttt.com" rel="noreferrer noreferrer" target="_blank">maker.ifttt.com</a><br>
<br>
My assumption is that systemd disables networking before the <br>
system-sleep scripts are run. Is there way I can use systemd to run the <br>
script before disabling the network?<br>
<br>
Thanks!<br>
<br>
Doug<br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>