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

lsof +fg doesn't recognize O_CLOEXEC in file flags on Linux #38

Closed
barsnick opened this issue May 9, 2019 · 7 comments
Closed

lsof +fg doesn't recognize O_CLOEXEC in file flags on Linux #38

barsnick opened this issue May 9, 2019 · 7 comments

Comments

@barsnick
Copy link

barsnick commented May 9, 2019

lsof +fg doesn't recognize O_CLOEXEC in file flags on Linux. It displays this flag as "0x80000". It should probably be displayed as "CX".

This was pointed out in this RedHat bugzilla issue.

I assume Linux's O_CLOEXEC is identical to other platforms' POF_CLOEXEC. I took a stab at this. Will post a PR.

barsnick added a commit to barsnick/lsof that referenced this issue May 9, 2019
@barsnick
Copy link
Author

barsnick commented May 9, 2019

This shows the change in behavior with this patch versus vanilla lsof:

$ diff -ub <(lsof +fg -p $$) <(./lsof +fg -p $$)
--- /dev/fd/63  2019-05-09 15:03:23.820280586 +0200
+++ /dev/fd/62  2019-05-09 15:03:23.822280571 +0200
@@ -13,5 +13,5 @@
 bash    631 barsnick    0u   CHR         RW,AP  136,2       0t0       5 /dev/pts/2
 bash    631 barsnick    1u   CHR         RW,AP  136,2       0t0       5 /dev/pts/2
 bash    631 barsnick    2u   CHR         RW,AP  136,2       0t0       5 /dev/pts/2
-bash    631 barsnick    3r   REG    LG,0x80000  253,0   8406312 1049099 /var/lib/sss/mc/passwd
-bash    631 barsnick  255u   CHR RW,AP,0x80000  136,2       0t0       5 /dev/pts/2
+bash    631 barsnick    3r   REG     CX,LG  253,0   8406312 1049099 /var/lib/sss/mc/passwd
+bash    631 barsnick  255u   CHR  RW,AP,CX  136,2       0t0       5 /dev/pts/2

I assume (and hope) this fix is valid and correct.

@masatake
Copy link
Contributor

masatake commented May 9, 2019

@masatake
Copy link
Contributor

masatake commented May 9, 2019

I forget to write "Thank you."

@masatake
Copy link
Contributor

masatake commented May 9, 2019

I have some patches about open flags at lsof-org/lsof-linux repo.

  /home/yamato/var/lsof-linux/patches/oflags:
  total used in directory 56 available 701427864
  drwxrwxr-x. 2 yamato yamato 4096 May  8 21:10 .
  drwxr-xr-x. 8 yamato yamato 8192 May  9 19:10 ..
  -rw-r--r--. 1 yamato yamato 1064 May  7 18:30 0016-fg-option-decode-O_PATH.patch
  -rw-r--r--. 1 yamato yamato 3375 May  7 18:30 0017-test-case-add-case-for-testing-O_PATH-decoder.patch
  -rw-r--r--. 1 yamato yamato 1117 May  7 18:30 0018-fg-option-decode-O_CLOEXEC.patch
  -rw-r--r--. 1 yamato yamato 1254 May  7 18:30 0019-test-case-add-case-for-testing-O_CLOEXEC-decoder.patch
  -rw-r--r--. 1 yamato yamato 1060 May  7 18:30 0020-fg-option-decode-O_TMPFILE.patch
  -rw-r--r--. 1 yamato yamato 1289 May  7 18:30 0021-test-case-add-case-for-testing-O_TMPFILE-decoder.patch
  -rw-r--r--. 1 yamato yamato  824 May  7 18:30 0023-test-case-make-the-result-failure-if-a-target-progra.patch
  -rw-r--r--. 1 yamato yamato  807 May  7 18:30 0024-test-case-fix-a-wrong-target-program-name.patch
  -rw-r--r--. 1 yamato yamato 2767 May  7 18:30 0025-fg-option-use-CX-as-as-short-hand-name-for-O_CLOEXEC.patch
  -rw-r--r--. 1 yamato yamato  835 May  7 18:30 0026-man-page-write-about-PATH-and-TMPF-fg-flags.patch

I will merge them.

@barsnick
Copy link
Author

barsnick commented May 9, 2019

I didn't realize there was a separate lsof-linux project. That's why I didn't find the modifications - I did search this repo of course. (I was confused by the move to github, which pointed to https://github.com/lsof-org/lsof.)

I'm the one to say thank you. Looking forward to those patches. Feel free to close this ticket if it is considered invalid.

@masatake
Copy link
Contributor

masatake commented May 9, 2019

I'm pulling changes in lsof-linux repo to this lsof repo now.
Still 30 patches remain...

@masatake
Copy link
Contributor

masatake commented May 9, 2019

Close via #40.

@masatake masatake closed this as completed May 9, 2019
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 a pull request may close this issue.

2 participants