factor out write_signal()

Also, let signal file message (if any) be of any arbitrary size.