Do write code that doesnt depend on side effects.
Do be very careful when writing signal handlers.
Do not modify global resources without locking.
Consider writing temporary files into a per- user store instead of a world-writable space.