Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow logging to process #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

a3f
Copy link
Member

@a3f a3f commented Aug 25, 2019

While microcom's stdout can be piped to another processes, it makes
input somewhat of a hassle. Address this by teaching the --logfile flag
and the log command that a filename starting with a pipe character refers
to an executable to start and pipe the input into. The child process shares
stderr, but has stdout closed.

Signed-off-by: Ahmad Fatoum <[email protected]>

This pull request is rebased on top of #9 to avoid the merge conflict. I'll rebase when the other one is merged.

Previously, a different process could create the lock between
both calls to open(2) with the result that two processes access
the same serial port. Fix this by specifying only opening the
lock file with O_CREAT | O_EXCL.

Signed-off-by: Ahmad Fatoum <[email protected]>
While at it remove the now outdated comment about kermit
compatibility.  It no longer applies to ckermit [1].

[1]: pengutronix#9 (comment)

Signed-off-by: Ahmad Fatoum <[email protected]>
If microcom crashes, e.g. due to the buffer underflow described in pengutronix#10,
it may leave a stale lock file behind. Teach microcom detection of
these stale lock files.

Signed-off-by: Ahmad Fatoum <[email protected]>
In preparation for piping the log into a file, mark existing file
descriptors so they are closed for exec'ing child processes.

Signed-off-by: Ahmad Fatoum <[email protected]>
While microcom's stdout can be piped to another processes, it makes
input somewhat of a hassle. Address this by teaching the --logfile
option and the log command that a filename starting with a pipe
character refers to an executable to start and pipe the input into.
The child process shares stderr, but has stdout closed.

Signed-off-by: Ahmad Fatoum <[email protected]>
@a3f
Copy link
Member Author

a3f commented Aug 25, 2019

I am not sure whether a --logexec command is more appropriate. Perl's open and Linux' /proc/sys/kernel/core_pattern are two examples I know of that interpret leading pipe as pipe-to-process instead of write-to-file, so I did it likewise.

@ukleinek
Copy link
Contributor

commit "Set O_CLOEXEC on newly opened file descriptors" looks fine. Didn't look in detail at the second patch yet. But as there are some changes requested in #9 I won't merge as is anyhow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants