Checking whether workspace is in use [message #541760] |
Tue, 22 June 2010 08:55  |
Eclipse User |
|
|
|
In a shell script in Linux I need to check whether a given workspace directory is in use by an open Eclipse instance.
In order to perform that, I used to look for this zeroed file: WORKSPACE/.metadata/.lock
However, it seems the current Eclipse 3.5 checking is no longer based on that file, as the latter remains stored in the directory even after closing the IDE.
So, how that workspace checking is made currently?
Thanks in advance.
Regards,
Rodrigo Hjort
http://agajorte.blogspot.com
|
|
|
|
|
Re: Checking whether workspace is in use [message #541867 is a reply to message #541843] |
Tue, 22 June 2010 15:51  |
Eclipse User |
|
|
|
"Rodrigo Hjort" <rodrigo_hjort@yahoo.com> wrote in message
news:hvqs3g$t0o$1@build.eclipse.org...
> Ed,
>
> Eclipse 3.5 definitely seems to ignore .lock file.
>
> Firstly, I started the IDE switching to a brand new worskpace. Then, there
> was the 0-bytes .lock file. But strangely it remains in .metadata
> directory after closing Eclipse.
>
> /tmp/ws/.metadata$ ls -la
> total 76
> drwxr-xr-x 4 user group 4096 2010-06-22 14:00 .
> drwxr-xr-x 4 user group 4096 2010-06-22 14:00 ..
> -rw-r--r-- 1 user group 0 2010-06-22 14:00 .lock
> -rw-r--r-- 1 user group 49973 2010-06-22 14:01 .log
> drwxr-xr-x 3 user group 4096 2010-06-22 14:00 .mylyn
> drwxr-xr-x 57 user group 4096 2010-06-22 14:00 .plugins
> -rw-r--r-- 1 user group 26 2010-06-22 14:01 version.ini
>
> Secondly, I tried to create another .lock file with an output stream (ls >
> .lock) as you suggested. I opened Eclipse and no error of workspace in use
> was raised.
>
> Here are the version specifications:
>
> Eclipse SDK
> Version: 3.5.2
> Build id: M20100211-1343
>
> Any other suggestion?
Eclipse workspace locking has become much more sophisticated over the years.
Simply checking for the existence of a .lock file would prevent Eclipse from
starting after a crash. Now Eclipse uses the java nio file locking
mechanism to lock the file. The file locks are release if the process
crashs so subsquent attempts to start Eclipse will be successful. However,
if you try to lock the file while Eclipse has the lock intact, it will fail.
You should be able to use a similar technique to check to see if Eclipse has
the workspace directory open.
|
|
|
Powered by
FUDForum. Page generated in 0.11150 seconds