PID of last running process in Windows

Loading...

PID of last running process in Windows

I want to grep the the PID of last running process in Windows. I am running the command in the background.

start "Window Title" /b "c:\Program Files\Wireshark\tshark.exe" -i
1 -w file1.pcap 
start "Window Title" /b "c:\Program
Files\Wireshark\tshark.exe" -i 1 -w file2.pcap

How do I get the PIDs of these commands?

Solutions/Answers:

Answer 1:

Possibly by tracking them.

When you start the first instance, you could use the tasklist command with the filter by the image name (see tasklist /?) to find the PID, which you would then store somewhere. (The output of tasklist can be parsed with the FOR /F command, see FOR /? for more info.)

Then, when you run the second instance, you do the same, but additionally filter out the stored PID (for example, using FIND /V, see FIND /? for more help), so you get only new instance’s PID. Store it as well to use later like the first one when you need to run a third instance.

Answer 2:

You can use wmic to launch the processes and get the pid from that. I’ve posted what I use for this as an answer to a similar question here.

References

Loading...

Python sys.maxint, sys.maxunicode on Linux and windows

Loading...

Python sys.maxint, sys.maxunicode on Linux and windows

On 64-bit Debian Linux 6:
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
9223372036854775807
>>> sys.maxunicode
1114111

On 64-bit Windows 7:
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
2147483647
>>> sys.maxunicode
65535

Both Operating Systems are 64-bit. They have sys.maxunicode, according to wikipedia There are 1,114,112 code points in unicode. Is sys.maxunicode on Windows wrong?
And why do they have different sys.maxint?

Solutions/Answers:

Answer 1:

I don’t know what your question is, but sys.maxunicode is not wrong on Windows.

See the docs:

sys.maxunicode

An integer giving the largest supported code point for a Unicode character. The value of this depends on the configuration option that
specifies whether Unicode characters are stored as UCS-2 or UCS-4.

Python on Windows uses UCS-2, so the largest code point is 65,535 (and the supplementary-plane characters are encoded by 2*16 bit “surrogate pairs”).

About sys.maxint, this shows at which point Python 2 switches from “simple integers” (123) to “long integers” (12345678987654321L). Obviously Python for Windows uses 32 bits, and Python for Linux uses 64 bits. Since Python 3, this has become irrelevant because the simple and long integer types have been merged into one. Therefore, sys.maxint is gone from Python 3.

Answer 2:

Regarding the difference is sys.maxint, see What is the bit size of long on 64-bit Windows?. Python uses the long type internally to store a small integer on Python 2.x.

References

Loading...