Comments (4)
I'll take a look to see how it's currently converted to String. Would be a breaking API change for current users though....so maybe need a variant of the method....
from libproc-rs.
For MacOS (Darwin):
The source here: https://opensource.apple.com/source/Libc/Libc-594.9.4/darwin/libproc.c is not exactly "replete with comments" about the type of string it writes into the buffer.
It calls __proc_info(2, pid, PROC_PIDPATHINFO, (uint64_t)0, buffer, buffersize);
I couldn't find the docs for that yet. Source is here: https://opensource.apple.com/source/xnu/xnu-792.13.8/bsd/kern/proc_info.c
It looks like that ends up calling vn_getpath(), which I'm still trying to find...it's header only says:
/*!
@function vn_getpath
@abstract Construct the path to a vnode.
@discussion Paths to vnodes are not always straightforward: a file with multiple hard-links will have multiple pathnames,
and it is sometimes impossible to determine a vnode's full path. vn_getpath() will not enter the filesystem.
@param vp The vnode whose path to obtain.
@param pathbuf Destination for pathname; should be of size MAXPATHLEN
@param len Destination for length of resulting path string. Result will include NULL-terminator in count--that is, "len"
will be strlen(pathbuf) + 1.
@return 0 for success or an error code.
*/
I wonder if any/all of these strings in the Mach/Darwin kernel are UTF-8?
For Linux:
I don't know, would have to investigate more.
Do you have knowledge of either/both OS to confirm the kernels can return buffers with non-UTF-8 strings for paths.
If so, I'd have to create a PathBuf from the raw buffer I imagine.
from libproc-rs.
I've just read two complete books on Mac OS X & iOS internals that covers BSD layer, Darwin, XNU, libSystem, libproc and the syscall wrappers - and annoyingly UTF and the nature of these strings returned in the buffers from syscals wasn't mentioned anywhere! :-(
from libproc-rs.
I guess this could use OSString?
Any suggestions on how to improve this to help improve for you?
from libproc-rs.
Related Issues (20)
- Add kcov coverage at codecov.io for Linux build HOT 1
- Remove uses of .expect() and replace with correct error handling
- Add calls that were added in 10.7
- Travis master cron build has started failing on Darwin/rust-stable HOT 2
- How to collect memory information for a process on non-Mac OS? HOT 10
- More detailed doc comments
- How can I get the current thread id? HOT 8
- macOS 11/Apple silicon showing high virtual memory usage HOT 19
- Update Github Action testing to macos-12 when available. HOT 1
- Create a mapping of OS version to XNU version to variants available HOT 1
- Fix tests threadinfo_test() and workqueueinfo_test() HOT 1
- Add V5 of usage struct with flags field
- macos11 nightly fails with clippy misaligned access warning
- Stable and Nightly fail due to unaligned access warning HOT 1
- Failed to build libproc bindings HOT 23
- Problems compiling in nixpkgs HOT 1
- MacOS: accept a typeinfo argument for listpids HOT 11
- see why "act" (for running GH Actions locally) fails
- Fix publishing of docs page HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libproc-rs.