Skip to content

Improved support for log rotation with candump #267

Closed
@richnetdesign

Description

@richnetdesign

As a user. tester or developer, sometimes I want to let candump log for extended periods of time. Log rotation is helpful to organize files by time, and to cap on max number of files for rotation. We don't need to add support to candump itself, we can simply adhere to conventions other unix tools use. It is a common pattern to accept a sighup signal to close an existing file, and start a new one without dropping any data. This is a pattern often used with the logrotate daemon. My goal is to add support to candump for this usecase.

Changes
1. Treats sighup as signal to close and reopen log file.
2. Since sighup can interrupt the select system call, now checking select error code for interupted sys call and logfile enabled. If those conditions are met, the errorcode is non critical.
3. Previously candump only supported autogenerated log file name by default. However, for use with logrotation daemon it expects consistent filename. I updated -l option to accept optional filename. Passing -l without argument maintains backwards compatibility.
4. Since interface is a required argument, I updated getopt to skip final arg. This was required to make -l argument optional.

Testing / Verification
While logging send SIGHUP signal
pkill --signal SIGHUP candump

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions