runinhibit

package
v0.0.0-...-2fb355d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package runinhibit contains operations for establishing, removing and querying snap run inhibition lock.

Index

Constants

This section is empty.

Variables

View Source
var InhibitDir = defaultInhibitDir

InhibitDir is the directory where inhibition files are stored. This value can be changed by calling dirs.SetRootDir.

Functions

func LockWithHint

func LockWithHint(snapName string, hint Hint) error

LockWithHint sets a persistent "snap run" inhibition lock, for the given snap, with a given hint.

The hint cannot be empty. It should be one of the Hint constants defined in this package. With the hint in place "snap run" will not allow the snap to start and will block, presenting a user interface if possible.

func RemoveLockFile

func RemoveLockFile(snapName string) error

RemoveLockFile removes the run inhibition lock for the given snap.

This function should not be used as a substitute of Unlock, as race-free ability to inspect the inhibition state relies on flock(2) which requires the file to exist in the first place and non-privileged processes cannot create it.

The function does not fail if the inhibition lock does not exist.

func Unlock

func Unlock(snapName string) error

Unlock truncates the run inhibition lock, for the given snap.

An empty inhibition lock means uninhibited "snap run".

Types

type Hint

type Hint string

Hint is a string representing reason for the inhibition of "snap run".

const (
	// HintNotInhibited is used when "snap run" is not inhibited.
	HintNotInhibited Hint = ""
	// HintInhibitedForRefresh represents inhibition of a "snap run" while a refresh change is being performed.
	HintInhibitedForRefresh Hint = "refresh"
)

func IsLocked

func IsLocked(snapName string) (Hint, error)

IsLocked returns the state of the run inhibition lock for the given snap.

It returns the current, non-empty hit if inhibition is in place. Otherwise it returns an empty hint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL