[cmake-developers] New command 'file(LOCK_DIRECTORY ...)'
Brad King
brad.king at kitware.com
Mon Nov 17 10:06:40 EST 2014
On 11/15/2014 03:34 AM, Rolf Eike Beer wrote:
> Ruslan Baratov wrote:
>> Done. Also I've found parse issue which is based on `sscanf` behaviour,
>> e.g. string '123xyz' will be successfully parsed as a integer (%d). Same
>> issue for example in file(STRINGS) command:
>
> I use strtol()/strtoul() for this kind of this, which also has a less
> worrisome interface.
Yes, please change to that so a proper error can be produced for the new
API when "123xyz" is given as a timeout, for example.
The file(STRINGS) command could be fixed with a separate change. In
order to be compatible it should do something like "%u%c" and produce
a warning if %c matched anything.
On 11/14/2014 06:27 PM, Ruslan Baratov wrote:
> On linux you can test timeout by:
> > cat script.cmake
> file(LOCK "${CMAKE_CURRENT_LIST_DIR}/file-to-lock" TIMEOUT 5)
> execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 10)
> > cmake -P script.cmake & # start one instance in background
> > cmake -P script.cmake # start second instance, expected lock failed
> by timeout
> CMake Error at script.cmake:1 (file):
> file : error locking file
> "/.../file-to-lock" (Timeout
> reached).
Please look at adding a case to the test suite for this. An outer
process could take the lock and then execute_process a child that
tries to take the lock with a timeout. Then check that it fails
as expected.
Thanks,
-Brad
More information about the cmake-developers
mailing list