jtorchat / jtorchat-old

Academic, Java, p2p, Messaging, Messenger, cyptography
21 stars 12 forks source link

On start, check and kill any errant tor processes in both windows and linux #4

Closed zerotamaitsu closed 12 years ago

zerotamaitsu commented 12 years ago

windows and linux should have some sort of command that allows us to kill old processes by process ID (e.g. taskkill)

jtorchat sometimes may not start because an old tor process was not shutdown properly. We need to on start of tor, write down the PID. On second start, if that tor PID is still booted, then we need to kill that process, and restart it.

A potential method that can do this is

java.lang.Runtime.exec

I presume its a case of checking if running linux or windows, and then running the right java.lang.Runtime.exec command.


For windows: http://www.addictivetips.com/windows-tips/kill-processes-from-the-command-prompt-in-windows-7/

jtorchat commented 12 years ago

on both system the automatically kill function from java not work correct. I have fix it under linux with pid but under windows it not work.

The problem is that we not can kill any tor, but we can try to find a pid under windows or the alternative that is the problem.

zerotamaitsu commented 12 years ago

hmmm... would this give you any ideas on what to do? (btw check your email)

@echo off

CONTENT OF start_jtorchat.bat

jtorchat.exe echo Dont press any key until you have closed jTorchat pause taskkill /F /IM obfsproxy.exe

Xexizy commented 12 years ago

Thats my batch file I made btw, and if you want it to work for this problem it would be

@echo off

jtorchat.exe echo Dont press any key until you have closed jTorchat pause taskkill /F /IM tor.exe

However be warned, this will also brake tor browser if you are using it due to the browser also using a process called tor.exe

jtorchat commented 12 years ago

This is bad for all people how have more then one tor.exe running. That is always a windows problem on linux i have a pid from the task.

zerotamaitsu commented 12 years ago

Can't we do some sort of pid equivalence for windows? I'm sure windows processes have an id too.

On Sat, Apr 14, 2012 at 2:14 PM, jtorchat < reply@reply.github.com

wrote:

This is bad for all people how have more then one tor.exe running. That is always a windows problem on linux i have a pid from the task.


Reply to this email directly or view it on GitHub: https://github.com/jtorchat/jtorchat/issues/4#issuecomment-5131570

Xexizy commented 12 years ago

Cant you just change the name of the process to jtor or something?

jtorchat commented 12 years ago

This is a solution, but not fine. When we do this you can only run one jtorchat instance but what when you will run two seperate?

Xexizy commented 12 years ago

When you try to run two jtorchat instances on the second one it says "the listener port is in use" and wont start up

Porlington commented 12 years ago

If you are trying to run two separate instances of jtorchat it would be more efficient to run your own tor instance configured for it.

Also, adding PidFile tor.pid to torrc will save tors pid in tor.pid.

zerotamaitsu commented 12 years ago

that "PidFile tor.pid" is a good idea, at least that will tackle the first problem of identifying the process. Now once that is done, we just need to work out how to kill each errant process for each platform. I think it should be done in TorLoader.java during the 'startup OS' detection stage.

On Mon, Apr 16, 2012 at 5:25 AM, Porlington < reply@reply.github.com

wrote:

If you are trying to run two separate instances of jtorchat it would be more efficient to run your own tor instance configured for it.

Also, adding PidFile tor.pid to torrc will save tors pid in tor.pid.


Reply to this email directly or view it on GitHub: https://github.com/jtorchat/jtorchat/issues/4#issuecomment-5145987

jtorchat commented 12 years ago

on linux pidfile already work but "PidFile tor.pid" on Windows?

zerotamaitsu commented 12 years ago

Okay here is the plan. We will add 'shutdown tor via pid number' for windows. But it will be during shutdown of jtorchat, not during the beginning (because we don't know of the old jtorchat is still running or not).

It wasn't fixed before, because we assumed that processbuilder would close tor.exe . Well it doesn't always do that.

zerotamaitsu commented 12 years ago

http://stackoverflow.com/questions/4633678/how-to-kill-a-process-in-java-given-a-specific-pid

ghost commented 12 years ago

We have now a menu to kill old jtor.exe and jobf.exe tasks. Works on linux and windows. (seperate commands).