Post

Replies

Boosts

Views

Activity

macOS: WiFi security type on Sonoma
In the context of a system utility that reports OS stats periodically, the security type for a connected WiFi network could be obtained with Core WLAN via CWInterface.security. This used to work up to Ventur; howver, after upgrading to Sonoma, cwInterface.security now returns kCWSecurityUnknown. In other posts, I have read about changes in how Core WLAN works which are related to Sonoma. How can I determine the security type for a connected WiFi network on Sonoma? It would be preferable if the suggested approach would also work on previous macOS versions as well. Many thanks in advance! :-)
2
0
1.2k
Oct ’23
What kind of file descriptors are counted in for ulimit/rlimit?
As a Developer, I want to provide a tool for sysadmins to determine how many files are open in the system. This is useful when combined with the information about resource limits (or ulimit) for processes. The lsof utility lists different types of open files, e.g. regular files and txt files. I have read the lsof source code extensively and would really like to know the following: 1.) Which open file descriptor types are counted by the kernel as part of the resource limit imposed on maximum open files. In other words: which file types as reported by lsof are counted in the open file statistics, such that opening more of them after reaching the resource limit would result in an error. 1.1.) Are txt files counted for the ulimit/resource limit? 2.) I don't quite understand what txt files are exactly. The manual says "program code and data", but what data exactly? I see things like: ULimitTes 20517 federico txt (...) /System/Library/Fonts/Apple Color Emoji.ttc being reported as a txt file. If I, however, open a file within a dynamic library (with fopen), that is then linked into a program and run, that file is reported with a corresponding file descriptor on lsof, e.g.: ULimitTes 20517 federico 6r REG (...) /Users/federico/INPUT I expected that file to be a txt file, given that it wasn't opened by the program itself but by a library used by the program. Any hints to further clarify the nature of txt files would be appreciated! 3.) If I setrlimit(RLIMIT_NPROC) to 2 in a program but attempt to open 3 files with fopen, this succeeds. I would have expected the third file open operation to fail, as the limit was set to 2. So what does the limit set by setrlimit(RLIMIT_NPROC) (and then verified by querying getrlimit(RLIMIT_NPROC)) do? Many thanks in advance for any hints on this! :-)
1
0
941
Apr ’23
macOS: what is the correct process priority?
Hello, I am collecting process performance metrics for an application. One of those metrics is the process' priority. I am confused by the fact that there seem to be two different priorities in the kernel: the BSD process priority (sysctl API) and the Mach task priority (proc_taskinfo API). Since I get two entirely different results for each one of them, I'd like to kindly ask for help understanding the relationship (if any) between them. On a related note: I have tried changing the nice value for a running process and it never seems to alter the priority (regardless of whether it is the BSD or the Mach priority). Is the nice value not used on XNU? Thanks a lot in advance for any hints! :-)
3
0
1.1k
Mar ’23
macOS: Private memory size for process?
Hi, I am trying to get some metrics on process memory usage that I haven't been able to determine using the available APIs for macOS. First, I'd like to learn how to obtain the Private memory size property that Activity Monitor displays in the detailed information for a process. I haven't found anything like it using the proc_taskinfo() or sysctl APIs. I also wonder about the relationship between the Private memory size from Activity Monitor and the BYTES ALLOCATED summary of vmmap. Second, I'd like to get the amount of virtual memory the process has reserved (Windows: "page file bytes"). Any hints would be greatly appreciated, as I have looked over all APIs and quite a bit of the XNU code without success! :-)
1
0
786
Mar ’23