andrewdavidmackenzie / libproc-rs

A rust library for getting information about running processes for Mac and Linux
MIT License
58 stars 17 forks source link

Linux support/project active? #5

Closed xd009642 closed 5 years ago

xd009642 commented 7 years ago

Hi, I'm interested in the libproc functionality for a Linux project I'm working on, but it looks like the project might be abandoned/dormant? Are there any plans to continue the project and what barriers are in the way of it working on linux?

I'm more than happy to contribute to attempt to get Linux support working and help out in general. Just let me know :smile:

andrewdavidmackenzie commented 7 years ago

Hi, I haven't done much on it lately... as I got busy on other stuff and I didn't have the time for it or the bigger project I planned to use it in (plus getting a bit lost by all the changes in different versions of Apple's OSS code and kernel...).

The Travis config allows errors in Linux with nightly rust, we could remove that and see what the status is on Linux. BTW: I develop on a Mac and the project I wanted to use this in was for Mac, so that's my main focus and given limited time unlikely to change much.... but I'd be happy to have others work on Linux....if we can get and keep CI passing on both, then I'll accept Prs...

xd009642 commented 7 years ago

That's fair enough, since posting the issue I found https://crates.io/crates/procinfo . While it doesn't look like it's actively maintained it does implement the features I need so I've gone with that in the meantime.

With that in mind I'm happy closing this issue if you are

andrewdavidmackenzie commented 7 years ago

I guess that crate gives you a solution for Linux, but is not cross platform?

Maybe it has code that could be used in a cross-platform solution?

I wanted to learn rust best practices for how to structure code when there are two completely different implementations for a functionality on two different platforms.... but hadn't got there yet..

If you want to help address that, or contribute to the code to make it functional on Linux, that would be great - but I won't be able to do myself directly.

I can see the demand for a cross-platform library, and that requires adding Linux support - so leaving the Issue open is fine by me...

xd009642 commented 7 years ago

It might be cross platform I'm not sure. Currently, I only target linux though so it's not an issue. At some point I might move to try and extend to apple or windows support but that's a very distant maybe. I might help out at some future point if I find limits with procinfo but I'm fairly busy so can't really promise anything.

For code that supports multiple platforms I found the nix crate is a good practical example. Libc is good if you need something more heavy duty but I haven't needed to go to that level yet :+1:

andrewdavidmackenzie commented 6 years ago

Do you have a specific call you would like implemented cross-platform to start with?

xd009642 commented 6 years ago

Not really, I was hoping to use this to identify the TIDs of a process to debug some ptrace code and maybe improve the multi-threading support of my coverage tool. I managed to make some other changes that improved performance though and haven't looked into this since. Though it may still prove useful I'd have to go back over the technical details in more depth.

andrewdavidmackenzie commented 5 years ago

Still interested in this lib being cross-platform, but don't have the time or the knowledge to tacked Lunix I'm afraid. If you want to try with the first simple methods that would be great.

It would force us to make the structs for pids, processes etc more generic.

andrewdavidmackenzie commented 5 years ago

OK, dug my linux laptop out of the cupboard. First step, get the linux build building (zero functionality) and passing in travis. Seond step, study procinfo and other Linux crates

andrewdavidmackenzie commented 5 years ago

First step done! https://github.com/andrewdavidmackenzie/libproc-rs/pull/30

Suggestions for what functions you'd like on both platforms welcome! (while I study /proc FS docs)

xd009642 commented 5 years ago

Ah cool :+1: I'll try and have a go at implementing some myself probably at the weekend as I've been fairly busy recently

andrewdavidmackenzie commented 5 years ago

with code like that in procinfo crate, and knowledge of what all the things in /proc are, I hope you can do quite a lot. https://github.com/danburkert/procinfo-rs/blob/master/src/pid/cwd.rs https://www.kernel.org/doc/Documentation/filesystems/proc.txt

If you can't develop on Mac... put an unimplemented!() and disable the test like I have done (for linux) for Mac, and ping me to see if I can do the Mac equivalent.

On Tue, Oct 8, 2019 at 9:44 PM xd009642 notifications@github.com wrote:

Ah cool 👍 I'll try and have a go at implementing some myself probably at the weekend as I've been fairly busy recently

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/andrewdavidmackenzie/libproc-rs/issues/5?email_source=notifications&email_token=ABKF4LCW3RBEJJ73MYLOEQLQNTPKJA5CNFSM4D65SDLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAVLZDI#issuecomment-539671693, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKF4LHGIYUHCDPO23Y3VU3QNTPKJANCNFSM4D65SDLA .

andrewdavidmackenzie commented 5 years ago

Will do pidcwd() and cwd_self() first for linux and see if I can implement a Mac version then. https://github.com/andrewdavidmackenzie/libproc-rs/pull/35

Bit of a pain to go back and fore on a PR, from two machines, but doable.

Just FYI

I'll close this issue now, I've opened a few teaser issues for Mac/Linux and added a label

andrewdavidmackenzie commented 5 years ago

FYI - a hacky first cross-platform function added ("name"). https://github.com/andrewdavidmackenzie/libproc-rs/pull/35

Not exactly an earth shattering contribution, but a start.