processtitle 0.2__tar.gz → 1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {processtitle-0.2/processtitle.egg-info → processtitle-1.1}/PKG-INFO +38 -11
  2. {processtitle-0.2 → processtitle-1.1}/README.md +36 -9
  3. {processtitle-0.2 → processtitle-1.1/processtitle.egg-info}/PKG-INFO +38 -11
  4. {processtitle-0.2 → processtitle-1.1}/processtitle.egg-info/SOURCES.txt +2 -0
  5. processtitle-1.1/processtitle.egg-info/entry_points.txt +2 -0
  6. {processtitle-0.2 → processtitle-1.1}/pyproject.toml +4 -1
  7. {processtitle-0.2 → processtitle-1.1}/src/cpp/bsd.h +2 -2
  8. {processtitle-0.2 → processtitle-1.1}/src/cpp/common.h +4 -0
  9. {processtitle-0.2 → processtitle-1.1}/src/processtitle/__init__.py +1 -1
  10. processtitle-1.1/src/processtitle/__main__.py +122 -0
  11. {processtitle-0.2 → processtitle-1.1}/Acknowledgments.md +0 -0
  12. {processtitle-0.2 → processtitle-1.1}/LICENSE +0 -0
  13. {processtitle-0.2 → processtitle-1.1}/MANIFEST.in +0 -0
  14. {processtitle-0.2 → processtitle-1.1}/processtitle.egg-info/dependency_links.txt +0 -0
  15. {processtitle-0.2 → processtitle-1.1}/processtitle.egg-info/top_level.txt +0 -0
  16. {processtitle-0.2 → processtitle-1.1}/setup.cfg +0 -0
  17. {processtitle-0.2 → processtitle-1.1}/setup.py +0 -0
  18. {processtitle-0.2 → processtitle-1.1}/src/cpp/clobber.cpp +0 -0
  19. {processtitle-0.2 → processtitle-1.1}/src/cpp/clobber.h +0 -0
  20. {processtitle-0.2 → processtitle-1.1}/src/cpp/darwin.cpp +0 -0
  21. {processtitle-0.2 → processtitle-1.1}/src/cpp/darwin.h +0 -0
  22. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/apple_cf_ptr.h +0 -0
  23. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/common.h +0 -0
  24. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/intrusive_shared_ptr.h +0 -0
  25. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/python_ptr.h +0 -0
  26. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/pylib/arguments.h +0 -0
  27. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/pylib/errors.h +0 -0
  28. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/pylib/locking.h +0 -0
  29. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/pylib/marshalling.h +0 -0
  30. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/pylib/method.h +0 -0
  31. {processtitle-0.2 → processtitle-1.1}/src/cpp/external/pylib/util.h +0 -0
  32. {processtitle-0.2 → processtitle-1.1}/src/cpp/linux.cpp +0 -0
  33. {processtitle-0.2 → processtitle-1.1}/src/cpp/linux.h +0 -0
  34. {processtitle-0.2 → processtitle-1.1}/src/cpp/logger.h +0 -0
  35. {processtitle-0.2 → processtitle-1.1}/src/cpp/main.cpp +0 -0
  36. {processtitle-0.2 → processtitle-1.1}/src/cpp/pch.h +0 -0
  37. {processtitle-0.2 → processtitle-1.1}/src/cpp/solaris.cpp +0 -0
  38. {processtitle-0.2 → processtitle-1.1}/src/cpp/solaris.h +0 -0
  39. {processtitle-0.2 → processtitle-1.1}/src/cpp/win.cpp +0 -0
  40. {processtitle-0.2 → processtitle-1.1}/src/cpp/win.h +0 -0
  41. {processtitle-0.2 → processtitle-1.1}/src/extension.cpp +0 -0
  42. {processtitle-0.2 → processtitle-1.1}/src/processtitle/_processtitle.pyi +0 -0
  43. {processtitle-0.2 → processtitle-1.1}/src/processtitle/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: processtitle
3
- Version: 0.2
3
+ Version: 1.1
4
4
  Summary: Customize process "title" as reported by ps and similar tools
5
5
  Author-email: Eugene Gershnik <gershnik@hotmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://github.com/gershnik/processtitle
9
9
  Project-URL: Issues, https://github.com/gershnik/processtitle/issues
10
10
  Project-URL: Changelog, https://github.com/gershnik/processtitle/blob/master/CHANGELOG.md
11
11
  Keywords: setproctitle,proctitle,process title,process name
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Operating System :: POSIX :: Linux
14
14
  Classifier: Operating System :: MacOS :: MacOS X
15
15
  Classifier: Operating System :: Microsoft :: Windows
@@ -36,6 +36,12 @@ Dynamic: license-file
36
36
 
37
37
  # processtitle
38
38
 
39
+ [![License](https://img.shields.io/badge/license-BSD-brightgreen.svg)](https://opensource.org/licenses/BSD-3-Clause)
40
+ [![python](https://img.shields.io/badge/python->=3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
41
+ [![pypi](https://img.shields.io/pypi/v/processtitle)](https://pypi.org/project/processtitle)
42
+ [![PyPI Downloads](https://static.pepy.tech/badge/processtitle)](https://pepy.tech/projects/processtitle)
43
+
44
+
39
45
  This Python extension module allows you to customize process "title" as reported by `ps`, `top`, Activity Monitor,
40
46
  Task Manager and similar tools.
41
47
 
@@ -68,7 +74,7 @@ to be shown in the process list instead.
68
74
  ## Platform support
69
75
 
70
76
  The module will happily _run_ and do nothing on any [compatible system](#requirements) but the ones where it
71
- actually _works_ (i.e. changes the process title) are: Linux, macOS, Windows, {Free|Net|Open}BSD and Illumos. See
77
+ actually _works_ (i.e. changes the process title) are: Linux, macOS, Windows, {Free|Net|Open|DragonFly}BSD and Illumos. See
72
78
  [platform details](#platform-details) below for more information about each platform.
73
79
 
74
80
  In all cases only reasonably recent versions of each platform are supported. No attempt is made to work
@@ -77,7 +83,7 @@ on ancient Linux kernels, Windows XP etc. etc. If you are stuck with a very old
77
83
 
78
84
  ## Requirements
79
85
 
80
- * Python >= 3.10 capable of loading native extensions
86
+ * Python >= 3.10 capable of loading native extensions. In particular, CPython, PyPy and GraalPy are all supported.
81
87
  * If your platform doesn't have a binary wheel available, you will need:
82
88
  * A C++ compiler capable of compiling C++20 (GCC 10.2 or above and CLang 13 or above are known to work)
83
89
  * Python development libraries available (like `python3-dev` package in most Linux distributions)
@@ -125,6 +131,16 @@ to a non-empty value (which is not "0"). For example:
125
131
  SPT_DEBUG=1 your_script_that_uses_processtitle
126
132
  ```
127
133
 
134
+ For troubleshooting and general convenience you can also call the module directly or via a wrapper script:
135
+ ```console
136
+ $ processtitle
137
+ $ #or
138
+ $ python3 -m processtitle
139
+ ```
140
+
141
+ This produces a list of process IDs and their titles by delegating to `ps` or Windows Powershell in a way
142
+ most appropriate to each platform. Run `processtitle -h` to see the available command line options.
143
+
128
144
  ## Thread and other safety
129
145
 
130
146
  `processtitle` _itself_ is thread-safe - all its operations are protected by a mutex. However,
@@ -170,12 +186,11 @@ In addition:
170
186
  ### Linux
171
187
 
172
188
  On Linux you will be able to see the process title in the output of `ps` or `top` commands, as well, as with any other
173
- tool that displays process info. Note that on some Linux variants (e.g. Alpine) the title might be prefixed or suffixed
174
- by the original process executable name. For example: `{python3} your title`.
189
+ tool that displays process info.
175
190
 
176
191
  To change the title, `processtitle` uses the following methods:
177
192
  * [PR_SET_MM](https://www.man7.org/linux/man-pages/man2/PR_SET_MM.2const.html) call.
178
- * [PR_SET_NAME](https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html)
193
+ * [PR_SET_NAME](https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html) call.
179
194
 
180
195
  `processtitle.set_to()` returns `True` if at least one of these methods succeeded.
181
196
 
@@ -209,7 +224,7 @@ To change the title, `processtitle` uses the following methods:
209
224
  ### Windows
210
225
 
211
226
  On Windows you can see the process by looking at the process command line. You can see the command lines of running
212
- processes in two ways:
227
+ processes in three ways:
213
228
 
214
229
  1. Using powershell's `Get-WmiObject Win32_Process` call:
215
230
  ```powershell
@@ -220,18 +235,30 @@ processes in two ways:
220
235
  powershell -c "Get-WmiObject Win32_Process | Select-Object ProcessId, CommandLine"
221
236
  ```
222
237
 
223
- 2. In Task Manager details view. If the "Command Line" column is not present, right-click the columns header,
238
+ 2. Using `processtitle` command line utility installed with this package. Run `processtitle -h` for
239
+ details of available switches. The utility internally uses WMI but in a more sophisticated way,
240
+
241
+ 3. In Task Manager details view. If the "Command Line" column is not present, right-click the columns header,
224
242
  choose "Select columns" and check "Command Line" entry in the list.
243
+
244
+ > [!IMPORTANT]
245
+ > Task Manager caches the command line of the process. If you had Task Manager open and showing the command
246
+ > line and *then* changed it, you might need to restart it to show the updated value.
225
247
 
226
248
  To change the title, `processtitle` uses modifies/replaces partially-documented [RTL_USER_PROCESS_PARAMETERS](https://learn.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters) via undocumented or partially documented calls.
227
249
 
228
250
  ### BSDs
229
251
 
230
- On {Free|Net|Open}BSD you will be able to see the process title in the output of `ps` or `top` commands, as well,
252
+ On {Free|Net|Open|DragonFly}BSD you will be able to see the process title in the output of `ps` or `top` commands, as well,
231
253
  as with any other tool that displays process info. All of these platforms will, in general, add the original
232
254
  executable name (e.g. `python3`) to the actual title either as a prefix or a suffix.
233
255
 
234
- To change the title, `processtitle` uses documented `setproctitle()` call ([FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3&format=html), [NetBSD](https://man.netbsd.org/NetBSD-10.1/setproctitle.3), [OpenBSD](https://man.openbsd.org/setproctitle.3)).
256
+ > [!NOTE]
257
+ > At the time of this writing the default compiler on DragonFly BSD is an ancient GCC 8. You will need to install
258
+ > GCC 11 (available as a binary package) in order to build `processtitle`. Once installed:
259
+ > `CC=gcc11 CXX=g++11 pip install processtitle`
260
+
261
+ To change the title, `processtitle` uses documented `setproctitle()` call ([FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3&format=html), [NetBSD](https://man.netbsd.org/NetBSD-10.1/setproctitle.3), [OpenBSD](https://man.openbsd.org/setproctitle.3), [DragonFly](https://man.dragonflybsd.org/?command=setproctitle)).
235
262
 
236
263
 
237
264
  ### Illumos
@@ -1,5 +1,11 @@
1
1
  # processtitle
2
2
 
3
+ [![License](https://img.shields.io/badge/license-BSD-brightgreen.svg)](https://opensource.org/licenses/BSD-3-Clause)
4
+ [![python](https://img.shields.io/badge/python->=3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
5
+ [![pypi](https://img.shields.io/pypi/v/processtitle)](https://pypi.org/project/processtitle)
6
+ [![PyPI Downloads](https://static.pepy.tech/badge/processtitle)](https://pepy.tech/projects/processtitle)
7
+
8
+
3
9
  This Python extension module allows you to customize process "title" as reported by `ps`, `top`, Activity Monitor,
4
10
  Task Manager and similar tools.
5
11
 
@@ -32,7 +38,7 @@ to be shown in the process list instead.
32
38
  ## Platform support
33
39
 
34
40
  The module will happily _run_ and do nothing on any [compatible system](#requirements) but the ones where it
35
- actually _works_ (i.e. changes the process title) are: Linux, macOS, Windows, {Free|Net|Open}BSD and Illumos. See
41
+ actually _works_ (i.e. changes the process title) are: Linux, macOS, Windows, {Free|Net|Open|DragonFly}BSD and Illumos. See
36
42
  [platform details](#platform-details) below for more information about each platform.
37
43
 
38
44
  In all cases only reasonably recent versions of each platform are supported. No attempt is made to work
@@ -41,7 +47,7 @@ on ancient Linux kernels, Windows XP etc. etc. If you are stuck with a very old
41
47
 
42
48
  ## Requirements
43
49
 
44
- * Python >= 3.10 capable of loading native extensions
50
+ * Python >= 3.10 capable of loading native extensions. In particular, CPython, PyPy and GraalPy are all supported.
45
51
  * If your platform doesn't have a binary wheel available, you will need:
46
52
  * A C++ compiler capable of compiling C++20 (GCC 10.2 or above and CLang 13 or above are known to work)
47
53
  * Python development libraries available (like `python3-dev` package in most Linux distributions)
@@ -89,6 +95,16 @@ to a non-empty value (which is not "0"). For example:
89
95
  SPT_DEBUG=1 your_script_that_uses_processtitle
90
96
  ```
91
97
 
98
+ For troubleshooting and general convenience you can also call the module directly or via a wrapper script:
99
+ ```console
100
+ $ processtitle
101
+ $ #or
102
+ $ python3 -m processtitle
103
+ ```
104
+
105
+ This produces a list of process IDs and their titles by delegating to `ps` or Windows Powershell in a way
106
+ most appropriate to each platform. Run `processtitle -h` to see the available command line options.
107
+
92
108
  ## Thread and other safety
93
109
 
94
110
  `processtitle` _itself_ is thread-safe - all its operations are protected by a mutex. However,
@@ -134,12 +150,11 @@ In addition:
134
150
  ### Linux
135
151
 
136
152
  On Linux you will be able to see the process title in the output of `ps` or `top` commands, as well, as with any other
137
- tool that displays process info. Note that on some Linux variants (e.g. Alpine) the title might be prefixed or suffixed
138
- by the original process executable name. For example: `{python3} your title`.
153
+ tool that displays process info.
139
154
 
140
155
  To change the title, `processtitle` uses the following methods:
141
156
  * [PR_SET_MM](https://www.man7.org/linux/man-pages/man2/PR_SET_MM.2const.html) call.
142
- * [PR_SET_NAME](https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html)
157
+ * [PR_SET_NAME](https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html) call.
143
158
 
144
159
  `processtitle.set_to()` returns `True` if at least one of these methods succeeded.
145
160
 
@@ -173,7 +188,7 @@ To change the title, `processtitle` uses the following methods:
173
188
  ### Windows
174
189
 
175
190
  On Windows you can see the process by looking at the process command line. You can see the command lines of running
176
- processes in two ways:
191
+ processes in three ways:
177
192
 
178
193
  1. Using powershell's `Get-WmiObject Win32_Process` call:
179
194
  ```powershell
@@ -184,18 +199,30 @@ processes in two ways:
184
199
  powershell -c "Get-WmiObject Win32_Process | Select-Object ProcessId, CommandLine"
185
200
  ```
186
201
 
187
- 2. In Task Manager details view. If the "Command Line" column is not present, right-click the columns header,
202
+ 2. Using `processtitle` command line utility installed with this package. Run `processtitle -h` for
203
+ details of available switches. The utility internally uses WMI but in a more sophisticated way,
204
+
205
+ 3. In Task Manager details view. If the "Command Line" column is not present, right-click the columns header,
188
206
  choose "Select columns" and check "Command Line" entry in the list.
207
+
208
+ > [!IMPORTANT]
209
+ > Task Manager caches the command line of the process. If you had Task Manager open and showing the command
210
+ > line and *then* changed it, you might need to restart it to show the updated value.
189
211
 
190
212
  To change the title, `processtitle` uses modifies/replaces partially-documented [RTL_USER_PROCESS_PARAMETERS](https://learn.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters) via undocumented or partially documented calls.
191
213
 
192
214
  ### BSDs
193
215
 
194
- On {Free|Net|Open}BSD you will be able to see the process title in the output of `ps` or `top` commands, as well,
216
+ On {Free|Net|Open|DragonFly}BSD you will be able to see the process title in the output of `ps` or `top` commands, as well,
195
217
  as with any other tool that displays process info. All of these platforms will, in general, add the original
196
218
  executable name (e.g. `python3`) to the actual title either as a prefix or a suffix.
197
219
 
198
- To change the title, `processtitle` uses documented `setproctitle()` call ([FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3&format=html), [NetBSD](https://man.netbsd.org/NetBSD-10.1/setproctitle.3), [OpenBSD](https://man.openbsd.org/setproctitle.3)).
220
+ > [!NOTE]
221
+ > At the time of this writing the default compiler on DragonFly BSD is an ancient GCC 8. You will need to install
222
+ > GCC 11 (available as a binary package) in order to build `processtitle`. Once installed:
223
+ > `CC=gcc11 CXX=g++11 pip install processtitle`
224
+
225
+ To change the title, `processtitle` uses documented `setproctitle()` call ([FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3&format=html), [NetBSD](https://man.netbsd.org/NetBSD-10.1/setproctitle.3), [OpenBSD](https://man.openbsd.org/setproctitle.3), [DragonFly](https://man.dragonflybsd.org/?command=setproctitle)).
199
226
 
200
227
 
201
228
  ### Illumos
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: processtitle
3
- Version: 0.2
3
+ Version: 1.1
4
4
  Summary: Customize process "title" as reported by ps and similar tools
5
5
  Author-email: Eugene Gershnik <gershnik@hotmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://github.com/gershnik/processtitle
9
9
  Project-URL: Issues, https://github.com/gershnik/processtitle/issues
10
10
  Project-URL: Changelog, https://github.com/gershnik/processtitle/blob/master/CHANGELOG.md
11
11
  Keywords: setproctitle,proctitle,process title,process name
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Operating System :: POSIX :: Linux
14
14
  Classifier: Operating System :: MacOS :: MacOS X
15
15
  Classifier: Operating System :: Microsoft :: Windows
@@ -36,6 +36,12 @@ Dynamic: license-file
36
36
 
37
37
  # processtitle
38
38
 
39
+ [![License](https://img.shields.io/badge/license-BSD-brightgreen.svg)](https://opensource.org/licenses/BSD-3-Clause)
40
+ [![python](https://img.shields.io/badge/python->=3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
41
+ [![pypi](https://img.shields.io/pypi/v/processtitle)](https://pypi.org/project/processtitle)
42
+ [![PyPI Downloads](https://static.pepy.tech/badge/processtitle)](https://pepy.tech/projects/processtitle)
43
+
44
+
39
45
  This Python extension module allows you to customize process "title" as reported by `ps`, `top`, Activity Monitor,
40
46
  Task Manager and similar tools.
41
47
 
@@ -68,7 +74,7 @@ to be shown in the process list instead.
68
74
  ## Platform support
69
75
 
70
76
  The module will happily _run_ and do nothing on any [compatible system](#requirements) but the ones where it
71
- actually _works_ (i.e. changes the process title) are: Linux, macOS, Windows, {Free|Net|Open}BSD and Illumos. See
77
+ actually _works_ (i.e. changes the process title) are: Linux, macOS, Windows, {Free|Net|Open|DragonFly}BSD and Illumos. See
72
78
  [platform details](#platform-details) below for more information about each platform.
73
79
 
74
80
  In all cases only reasonably recent versions of each platform are supported. No attempt is made to work
@@ -77,7 +83,7 @@ on ancient Linux kernels, Windows XP etc. etc. If you are stuck with a very old
77
83
 
78
84
  ## Requirements
79
85
 
80
- * Python >= 3.10 capable of loading native extensions
86
+ * Python >= 3.10 capable of loading native extensions. In particular, CPython, PyPy and GraalPy are all supported.
81
87
  * If your platform doesn't have a binary wheel available, you will need:
82
88
  * A C++ compiler capable of compiling C++20 (GCC 10.2 or above and CLang 13 or above are known to work)
83
89
  * Python development libraries available (like `python3-dev` package in most Linux distributions)
@@ -125,6 +131,16 @@ to a non-empty value (which is not "0"). For example:
125
131
  SPT_DEBUG=1 your_script_that_uses_processtitle
126
132
  ```
127
133
 
134
+ For troubleshooting and general convenience you can also call the module directly or via a wrapper script:
135
+ ```console
136
+ $ processtitle
137
+ $ #or
138
+ $ python3 -m processtitle
139
+ ```
140
+
141
+ This produces a list of process IDs and their titles by delegating to `ps` or Windows Powershell in a way
142
+ most appropriate to each platform. Run `processtitle -h` to see the available command line options.
143
+
128
144
  ## Thread and other safety
129
145
 
130
146
  `processtitle` _itself_ is thread-safe - all its operations are protected by a mutex. However,
@@ -170,12 +186,11 @@ In addition:
170
186
  ### Linux
171
187
 
172
188
  On Linux you will be able to see the process title in the output of `ps` or `top` commands, as well, as with any other
173
- tool that displays process info. Note that on some Linux variants (e.g. Alpine) the title might be prefixed or suffixed
174
- by the original process executable name. For example: `{python3} your title`.
189
+ tool that displays process info.
175
190
 
176
191
  To change the title, `processtitle` uses the following methods:
177
192
  * [PR_SET_MM](https://www.man7.org/linux/man-pages/man2/PR_SET_MM.2const.html) call.
178
- * [PR_SET_NAME](https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html)
193
+ * [PR_SET_NAME](https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html) call.
179
194
 
180
195
  `processtitle.set_to()` returns `True` if at least one of these methods succeeded.
181
196
 
@@ -209,7 +224,7 @@ To change the title, `processtitle` uses the following methods:
209
224
  ### Windows
210
225
 
211
226
  On Windows you can see the process by looking at the process command line. You can see the command lines of running
212
- processes in two ways:
227
+ processes in three ways:
213
228
 
214
229
  1. Using powershell's `Get-WmiObject Win32_Process` call:
215
230
  ```powershell
@@ -220,18 +235,30 @@ processes in two ways:
220
235
  powershell -c "Get-WmiObject Win32_Process | Select-Object ProcessId, CommandLine"
221
236
  ```
222
237
 
223
- 2. In Task Manager details view. If the "Command Line" column is not present, right-click the columns header,
238
+ 2. Using `processtitle` command line utility installed with this package. Run `processtitle -h` for
239
+ details of available switches. The utility internally uses WMI but in a more sophisticated way,
240
+
241
+ 3. In Task Manager details view. If the "Command Line" column is not present, right-click the columns header,
224
242
  choose "Select columns" and check "Command Line" entry in the list.
243
+
244
+ > [!IMPORTANT]
245
+ > Task Manager caches the command line of the process. If you had Task Manager open and showing the command
246
+ > line and *then* changed it, you might need to restart it to show the updated value.
225
247
 
226
248
  To change the title, `processtitle` uses modifies/replaces partially-documented [RTL_USER_PROCESS_PARAMETERS](https://learn.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters) via undocumented or partially documented calls.
227
249
 
228
250
  ### BSDs
229
251
 
230
- On {Free|Net|Open}BSD you will be able to see the process title in the output of `ps` or `top` commands, as well,
252
+ On {Free|Net|Open|DragonFly}BSD you will be able to see the process title in the output of `ps` or `top` commands, as well,
231
253
  as with any other tool that displays process info. All of these platforms will, in general, add the original
232
254
  executable name (e.g. `python3`) to the actual title either as a prefix or a suffix.
233
255
 
234
- To change the title, `processtitle` uses documented `setproctitle()` call ([FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3&format=html), [NetBSD](https://man.netbsd.org/NetBSD-10.1/setproctitle.3), [OpenBSD](https://man.openbsd.org/setproctitle.3)).
256
+ > [!NOTE]
257
+ > At the time of this writing the default compiler on DragonFly BSD is an ancient GCC 8. You will need to install
258
+ > GCC 11 (available as a binary package) in order to build `processtitle`. Once installed:
259
+ > `CC=gcc11 CXX=g++11 pip install processtitle`
260
+
261
+ To change the title, `processtitle` uses documented `setproctitle()` call ([FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3&format=html), [NetBSD](https://man.netbsd.org/NetBSD-10.1/setproctitle.3), [OpenBSD](https://man.openbsd.org/setproctitle.3), [DragonFly](https://man.dragonflybsd.org/?command=setproctitle)).
235
262
 
236
263
 
237
264
  ### Illumos
@@ -7,6 +7,7 @@ setup.py
7
7
  processtitle.egg-info/PKG-INFO
8
8
  processtitle.egg-info/SOURCES.txt
9
9
  processtitle.egg-info/dependency_links.txt
10
+ processtitle.egg-info/entry_points.txt
10
11
  processtitle.egg-info/top_level.txt
11
12
  src/extension.cpp
12
13
  src/cpp/bsd.h
@@ -35,5 +36,6 @@ src/cpp/external/pylib/marshalling.h
35
36
  src/cpp/external/pylib/method.h
36
37
  src/cpp/external/pylib/util.h
37
38
  src/processtitle/__init__.py
39
+ src/processtitle/__main__.py
38
40
  src/processtitle/_processtitle.pyi
39
41
  src/processtitle/py.typed
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ processtitle = processtitle.__main__:main
@@ -33,7 +33,7 @@ keywords = [
33
33
  'setproctitle', 'proctitle', 'process title', 'process name'
34
34
  ]
35
35
  classifiers = [
36
- "Development Status :: 4 - Beta",
36
+ "Development Status :: 5 - Production/Stable",
37
37
 
38
38
  "Operating System :: POSIX :: Linux",
39
39
  "Operating System :: MacOS :: MacOS X",
@@ -64,3 +64,6 @@ Homepage = 'https://github.com/gershnik/processtitle'
64
64
  Documentation = 'https://github.com/gershnik/processtitle'
65
65
  Issues = 'https://github.com/gershnik/processtitle/issues'
66
66
  Changelog = 'https://github.com/gershnik/processtitle/blob/master/CHANGELOG.md'
67
+
68
+ [project.scripts]
69
+ processtitle = 'processtitle.__main__:main'
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "common.h"
5
5
 
6
- #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
6
+ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
7
7
 
8
8
  #define SPTEX_HAS_BSD 1
9
9
 
@@ -12,7 +12,7 @@ void bsdPrepare() {
12
12
  }
13
13
 
14
14
  bool bsdSetProcessTitle(const char * title) {
15
- #if defined(__FreeBSD__)
15
+ #if defined(__FreeBSD__) || defined(__DragonFly__)
16
16
  setproctitle("-%s", title);
17
17
  #else
18
18
  setproctitle("%s", title);
@@ -27,6 +27,8 @@ struct Overloads : Ts... { using Ts::operator()...; };
27
27
  template<class T>
28
28
  constexpr bool dependentFalse = false;
29
29
 
30
+ #ifndef _WIN32
31
+
30
32
  class FileDescriptor {
31
33
  public:
32
34
  FileDescriptor() noexcept = default;
@@ -114,3 +116,5 @@ inline auto readFile(const FileDescriptor & desc, void * buf, io_size_t nbyte) -
114
116
  }
115
117
 
116
118
  #endif
119
+
120
+ #endif
@@ -6,7 +6,7 @@
6
6
  import os
7
7
  import logging
8
8
 
9
- __version__ = '0.2'
9
+ __version__ = '1.1'
10
10
 
11
11
  from ._processtitle import (
12
12
  prepare,
@@ -0,0 +1,122 @@
1
+ # Copyright (c) 2026, Eugene Gershnik
2
+ # SPDX-License-Identifier: BSD-3-Clause
3
+
4
+ """Command line utility to list process titles"""
5
+
6
+ import sys
7
+ import os
8
+ import argparse
9
+ import subprocess
10
+ import shutil
11
+ import re
12
+ import textwrap
13
+ import locale
14
+
15
+ from pathlib import Path
16
+
17
+ from . import __version__
18
+
19
+ def _doBusybox(args, ps: Path):
20
+ cmd = [ps, '-opid,args']
21
+ if args.pids is None:
22
+ proc = subprocess.run(cmd)
23
+ return proc.returncode
24
+
25
+ encoding = locale.getpreferredencoding(do_setlocale=False)
26
+ proc = subprocess.Popen(cmd, encoding=encoding, stdout=subprocess.PIPE)
27
+ assert proc.stdout is not None
28
+ expr = re.compile(r'^\s*([0-9]+) ')
29
+ for line in proc.stdout:
30
+ if (m := expr.search(line)):
31
+ pid = int(m.group(1))
32
+ if pid in args.pids:
33
+ print(line, end='')
34
+ else:
35
+ print(line, end='')
36
+ retcode = proc.wait()
37
+ return retcode
38
+
39
+ def _doUnix(args):
40
+ path = os.environ.get('PATH', '/bin:/usr/bin')
41
+ ps = shutil.which('ps', path=path)
42
+ if ps is None:
43
+ print('ps utility not found', file=sys.stderr, flush=True)
44
+ return 1
45
+
46
+ test = Path(ps)
47
+ while test.is_symlink():
48
+ dest = test.readlink()
49
+ if dest.name == 'busybox':
50
+ return _doBusybox(args, Path(ps))
51
+
52
+ cmd = [ps]
53
+
54
+ if sys.platform.startswith("sunos"):
55
+ cmd += ['-F', '-opid,args']
56
+ else:
57
+ cmd += ['-opid,command']
58
+
59
+ if args.pids is not None:
60
+ if sys.platform == "linux":
61
+ cmd += ['-q', ','.join([str(pid) for pid in args.pids])]
62
+ else:
63
+ cmd += ['-p', ','.join([str(pid) for pid in args.pids])]
64
+ elif args.show_all:
65
+ cmd += ['-A']
66
+
67
+ proc = subprocess.run(cmd)
68
+ return proc.returncode
69
+
70
+
71
+ def _doWin(args):
72
+ powershell = shutil.which('powershell')
73
+ if powershell is None:
74
+ print('powershell not found', file=sys.stderr, flush=True)
75
+ return 1
76
+
77
+ pids = ''
78
+ filter = ''
79
+ if not args.show_all:
80
+ filter += '| Where-Object { $sessionId -eq $_.SessionId } '
81
+ if args.pids is not None:
82
+ pids = ', '.join(str(pid) for pid in args.pids)
83
+ filter += '| Where-Object { $pids -contains $_.ProcessId } '
84
+ input = textwrap.dedent('''
85
+ $ErrorActionPreference = 'Stop'
86
+ $pids = @( ''' + pids + ''' )
87
+ $sessionId = [System.Diagnostics.Process]::GetCurrentProcess().SessionId
88
+ $s = Get-CimInstance Win32_Process ''' + filter + '''| Format-Table -Property @(
89
+ @{ Name='PID'; Expression = { $_.ProcessId }}
90
+ @{ Name='COMMAND'; Expression = { If ($_.CommandLine.Length) {$_.CommandLine} else {$_.Name} }}
91
+ ) | Out-String
92
+ $s = $s.Trim()
93
+ if ($s -eq '') { exit 1 }
94
+ $s
95
+ ''').replace('\n', '\r\n')
96
+
97
+ cmd = [powershell, '-NonInteractive', '-NoLogo', '-Command', '-']
98
+ proc = subprocess.run(cmd, input=input, encoding='utf-8')
99
+ return proc.returncode
100
+
101
+ def main():
102
+ """script entry point"""
103
+
104
+ parser = argparse.ArgumentParser(
105
+ prog='processtitle',
106
+ description='Portably lists process IDs and their titles'
107
+ )
108
+ parser.add_argument('-a', '--all', action='store_true', dest='show_all',
109
+ help="show all (as opposed to 'some') processes. "
110
+ "The definition of 'some' is platform dependent.")
111
+ parser.add_argument('-p', '--pid', metavar='PID', type=int, nargs='+', dest='pids', help='limit output to these process IDs')
112
+ parser.add_argument('-v', '--version', action='version', version=f'%(prog)s {__version__}')
113
+
114
+ args = parser.parse_args()
115
+
116
+ if not sys.platform.startswith("win32"):
117
+ return _doUnix(args)
118
+ else:
119
+ return _doWin(args)
120
+
121
+ if __name__ == '__main__':
122
+ sys.exit(main())
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes