attestationd: fork before starting the daemon.

This change adds a call to daemon(3) function to fork in the background.
This is required so upstart can know when the program has been
initialized (post-start scripts are executed after upstart gets the
child pid).

This change is required in order to support zerotouch enrollment in
attestationd the same way it is being used in cryptohomed: there's a
file that has to be read and deleted as soon as possible. This change
gives us a synchronization point to know when the program has been
initialized (forked).

TEST=tested on a fizz board: both cryptohomed and attestationd can
communicate with each other. start and stop works for both daemons, and
there were no crashes in /var/log/messages. I was able to run commands
with trunks_client, tpm_manager_client, attestation_client and

Change-Id: I88f4b26b90cbc75fe361c219213091379ada4bd8
Commit-Ready: Marco Vanotti <>
Tested-by: Marco Vanotti <>
Reviewed-by: Yves Arrouye <>
Reviewed-by: Andrey Pronin <>
2 files changed