acquire_file_lock Subroutine

public subroutine acquire_file_lock(path, lock_fd, status)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path
integer, intent(out) :: lock_fd
integer, intent(out) :: status

Called by

proc~~acquire_file_lock~~CalledByGraph proc~acquire_file_lock acquire_file_lock proc~precompute_periodic_root_operator precompute_periodic_root_operator proc~precompute_periodic_root_operator->proc~acquire_file_lock proc~core_build_panel_plan_impl core_build_panel_plan_impl proc~core_build_panel_plan_impl->proc~precompute_periodic_root_operator proc~core_build_plan_impl core_build_plan_impl proc~core_build_plan_impl->proc~precompute_periodic_root_operator

Source Code

  subroutine acquire_file_lock(path, lock_fd, status)
    character(len=*), intent(in) :: path
    integer, intent(out) :: lock_fd, status
    character(kind=c_char), allocatable :: c_path(:)
    integer(c_int) :: fd, close_status

    lock_fd = -1
    if (len_trim(path) == 0) then
      status = filesystem_empty_path
      return
    end if
    call to_c_string(trim(path), c_path)
    fd = c_open(c_path, open_write_create, file_mode)
    if (fd < 0_c_int) then
      status = filesystem_os_error
      return
    end if
    if (c_flock(fd, lock_exclusive) /= 0_c_int) then
      status = filesystem_os_error
      close_status = c_close(fd)
      return
    end if
    lock_fd = int(fd)
    status = filesystem_success
  end subroutine acquire_file_lock