nebraska: Make runtime files creation atomic

Users of nebraska look for the existence of the port and pid files and
then read their content. If they read the content after the file(s) are
created but before they are written into, then problems can occur. In
this CL we first create partial files and then move them into their
final locations atomically.

BUG=b:179329819
TEST=./nebraska.py --runtime-root /tmp --log-file stdout

Change-Id: I6bf5307b68017657451e912b5517e36988d33c8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2681308
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
1 file changed