-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO
38 lines (29 loc) · 2.45 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Ignore the below. We may just start three threads to watch for:
stdin, stdout, waitFor(). Not an efficient solution but simple and portable.
The ONLY way to deal well asyncronously is write our own ProcessBuilder analog.
Hm, but what to do with waitFor()?
When using a separate thread to .waitFor() and something like
java.nio.channels.Selector with a pair of pipes to inform the main thread
about process exit. When using Selector, we will check if data is available
on stdin/stdout even if we received a character from our pipe, to be sure
and exit from the loop only after last "flush" of the in/out pipes.
Also use `timeout` arg of select().
On using ProcessBuilder:
https://www.javaworld.com/article/2074830/core-java/the-pain-of-broken-subprocess-management-on-jdk.html
porton, Runtime.exec(), ProcessBuilder, etc are tricky beasts. The rules: 1: Always use ProcessBuilder. 2: Consider using http://github.com/johnlcox/process-warden as it works around most trickery and pitfalls. 3: exec() and co directly start processes, it's not like the command line. No processing is done on your parameters. 4: You need to empty both standard out and standard err, or use pb.redirectErrorStream, or the process will eventually hang.
<dreamreal> but you're doing it in a really roundabout manner
<dreamreal> ~zt-exec
<javabot> zt-exec is a nicer wrapper about Process and ProcessBuilder by the zeroturnaround engineers. https://github.com/zeroturnaround/zt-exec
~no process is Runtime.exec(), ProcessBuilder, etc are tricky beasts. The rules: 1: Always use ProcessBuilder. 2: Consider using http://github.com/johnlcox/process-warden or ~zt-exec as they work around most trickery and pitfalls. 3: exec() and co directly start processes, it's not like the command line. No processing is done on your parameters. 4: You need to empty both standard out and standard err, or use pb.redirectErrorStream, or the process will
Tey also http://commons.apache.org/proper/commons-exec/ to spawn processes.
* How to "import" in Python through the network:
https://docs.python.org/3/reference/import.html#replacing-the-standard-import-system
* The upstream version of a Debian package can be deterministically
extracted from the package version, see https://www.debian.org/doc/debian-policy/#s-f-version
for the format.
Also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=883133
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() { /*
my shutdown code here
*/ }
});