processtitle 1.0__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-1.0/processtitle.egg-info → processtitle-1.1}/PKG-INFO +28 -6
  2. {processtitle-1.0 → processtitle-1.1}/README.md +27 -5
  3. {processtitle-1.0 → processtitle-1.1/processtitle.egg-info}/PKG-INFO +28 -6
  4. {processtitle-1.0 → processtitle-1.1}/processtitle.egg-info/SOURCES.txt +2 -0
  5. processtitle-1.1/processtitle.egg-info/entry_points.txt +2 -0
  6. {processtitle-1.0 → processtitle-1.1}/pyproject.toml +3 -0
  7. {processtitle-1.0 → processtitle-1.1}/src/cpp/bsd.h +2 -2
  8. {processtitle-1.0 → processtitle-1.1}/src/processtitle/__init__.py +1 -1
  9. processtitle-1.1/src/processtitle/__main__.py +122 -0
  10. {processtitle-1.0 → processtitle-1.1}/Acknowledgments.md +0 -0
  11. {processtitle-1.0 → processtitle-1.1}/LICENSE +0 -0
  12. {processtitle-1.0 → processtitle-1.1}/MANIFEST.in +0 -0
  13. {processtitle-1.0 → processtitle-1.1}/processtitle.egg-info/dependency_links.txt +0 -0
  14. {processtitle-1.0 → processtitle-1.1}/processtitle.egg-info/top_level.txt +0 -0
  15. {processtitle-1.0 → processtitle-1.1}/setup.cfg +0 -0
  16. {processtitle-1.0 → processtitle-1.1}/setup.py +0 -0
  17. {processtitle-1.0 → processtitle-1.1}/src/cpp/clobber.cpp +0 -0
  18. {processtitle-1.0 → processtitle-1.1}/src/cpp/clobber.h +0 -0
  19. {processtitle-1.0 → processtitle-1.1}/src/cpp/common.h +0 -0
  20. {processtitle-1.0 → processtitle-1.1}/src/cpp/darwin.cpp +0 -0
  21. {processtitle-1.0 → processtitle-1.1}/src/cpp/darwin.h +0 -0
  22. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/apple_cf_ptr.h +0 -0
  23. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/common.h +0 -0
  24. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/intrusive_shared_ptr.h +0 -0
  25. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/intrusive_shared_ptr/python_ptr.h +0 -0
  26. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/pylib/arguments.h +0 -0
  27. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/pylib/errors.h +0 -0
  28. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/pylib/locking.h +0 -0
  29. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/pylib/marshalling.h +0 -0
  30. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/pylib/method.h +0 -0
  31. {processtitle-1.0 → processtitle-1.1}/src/cpp/external/pylib/util.h +0 -0
  32. {processtitle-1.0 → processtitle-1.1}/src/cpp/linux.cpp +0 -0
  33. {processtitle-1.0 → processtitle-1.1}/src/cpp/linux.h +0 -0
  34. {processtitle-1.0 → processtitle-1.1}/src/cpp/logger.h +0 -0
  35. {processtitle-1.0 → processtitle-1.1}/src/cpp/main.cpp +0 -0
  36. {processtitle-1.0 → processtitle-1.1}/src/cpp/pch.h +0 -0
  37. {processtitle-1.0 → processtitle-1.1}/src/cpp/solaris.cpp +0 -0
  38. {processtitle-1.0 → processtitle-1.1}/src/cpp/solaris.h +0 -0
  39. {processtitle-1.0 → processtitle-1.1}/src/cpp/win.cpp +0 -0
  40. {processtitle-1.0 → processtitle-1.1}/src/cpp/win.h +0 -0
  41. {processtitle-1.0 → processtitle-1.1}/src/extension.cpp +0 -0
  42. {processtitle-1.0 → processtitle-1.1}/src/processtitle/_processtitle.pyi +0 -0
  43. {processtitle-1.0 → 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: 1.0
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
@@ -74,7 +74,7 @@ to be shown in the process list instead.
74
74
  ## Platform support
75
75
 
76
76
  The module will happily _run_ and do nothing on any [compatible system](#requirements) but the ones where it
77
- 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
78
78
  [platform details](#platform-details) below for more information about each platform.
79
79
 
80
80
  In all cases only reasonably recent versions of each platform are supported. No attempt is made to work
@@ -131,6 +131,16 @@ to a non-empty value (which is not "0"). For example:
131
131
  SPT_DEBUG=1 your_script_that_uses_processtitle
132
132
  ```
133
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
+
134
144
  ## Thread and other safety
135
145
 
136
146
  `processtitle` _itself_ is thread-safe - all its operations are protected by a mutex. However,
@@ -214,7 +224,7 @@ To change the title, `processtitle` uses the following methods:
214
224
  ### Windows
215
225
 
216
226
  On Windows you can see the process by looking at the process command line. You can see the command lines of running
217
- processes in two ways:
227
+ processes in three ways:
218
228
 
219
229
  1. Using powershell's `Get-WmiObject Win32_Process` call:
220
230
  ```powershell
@@ -225,18 +235,30 @@ processes in two ways:
225
235
  powershell -c "Get-WmiObject Win32_Process | Select-Object ProcessId, CommandLine"
226
236
  ```
227
237
 
228
- 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,
229
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.
230
247
 
231
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.
232
249
 
233
250
  ### BSDs
234
251
 
235
- 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,
236
253
  as with any other tool that displays process info. All of these platforms will, in general, add the original
237
254
  executable name (e.g. `python3`) to the actual title either as a prefix or a suffix.
238
255
 
239
- 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)).
240
262
 
241
263
 
242
264
  ### Illumos
@@ -38,7 +38,7 @@ to be shown in the process list instead.
38
38
  ## Platform support
39
39
 
40
40
  The module will happily _run_ and do nothing on any [compatible system](#requirements) but the ones where it
41
- 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
42
42
  [platform details](#platform-details) below for more information about each platform.
43
43
 
44
44
  In all cases only reasonably recent versions of each platform are supported. No attempt is made to work
@@ -95,6 +95,16 @@ to a non-empty value (which is not "0"). For example:
95
95
  SPT_DEBUG=1 your_script_that_uses_processtitle
96
96
  ```
97
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
+
98
108
  ## Thread and other safety
99
109
 
100
110
  `processtitle` _itself_ is thread-safe - all its operations are protected by a mutex. However,
@@ -178,7 +188,7 @@ To change the title, `processtitle` uses the following methods:
178
188
  ### Windows
179
189
 
180
190
  On Windows you can see the process by looking at the process command line. You can see the command lines of running
181
- processes in two ways:
191
+ processes in three ways:
182
192
 
183
193
  1. Using powershell's `Get-WmiObject Win32_Process` call:
184
194
  ```powershell
@@ -189,18 +199,30 @@ processes in two ways:
189
199
  powershell -c "Get-WmiObject Win32_Process | Select-Object ProcessId, CommandLine"
190
200
  ```
191
201
 
192
- 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,
193
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.
194
211
 
195
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.
196
213
 
197
214
  ### BSDs
198
215
 
199
- 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,
200
217
  as with any other tool that displays process info. All of these platforms will, in general, add the original
201
218
  executable name (e.g. `python3`) to the actual title either as a prefix or a suffix.
202
219
 
203
- 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)).
204
226
 
205
227
 
206
228
  ### Illumos
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: processtitle
3
- Version: 1.0
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
@@ -74,7 +74,7 @@ to be shown in the process list instead.
74
74
  ## Platform support
75
75
 
76
76
  The module will happily _run_ and do nothing on any [compatible system](#requirements) but the ones where it
77
- 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
78
78
  [platform details](#platform-details) below for more information about each platform.
79
79
 
80
80
  In all cases only reasonably recent versions of each platform are supported. No attempt is made to work
@@ -131,6 +131,16 @@ to a non-empty value (which is not "0"). For example:
131
131
  SPT_DEBUG=1 your_script_that_uses_processtitle
132
132
  ```
133
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
+
134
144
  ## Thread and other safety
135
145
 
136
146
  `processtitle` _itself_ is thread-safe - all its operations are protected by a mutex. However,
@@ -214,7 +224,7 @@ To change the title, `processtitle` uses the following methods:
214
224
  ### Windows
215
225
 
216
226
  On Windows you can see the process by looking at the process command line. You can see the command lines of running
217
- processes in two ways:
227
+ processes in three ways:
218
228
 
219
229
  1. Using powershell's `Get-WmiObject Win32_Process` call:
220
230
  ```powershell
@@ -225,18 +235,30 @@ processes in two ways:
225
235
  powershell -c "Get-WmiObject Win32_Process | Select-Object ProcessId, CommandLine"
226
236
  ```
227
237
 
228
- 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,
229
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.
230
247
 
231
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.
232
249
 
233
250
  ### BSDs
234
251
 
235
- 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,
236
253
  as with any other tool that displays process info. All of these platforms will, in general, add the original
237
254
  executable name (e.g. `python3`) to the actual title either as a prefix or a suffix.
238
255
 
239
- 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)).
240
262
 
241
263
 
242
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
@@ -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);
@@ -6,7 +6,7 @@
6
6
  import os
7
7
  import logging
8
8
 
9
- __version__ = '1.0'
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
File without changes