shellmate-0.3.4.2: Simple interface for shell scripting in Haskell.

Safe HaskellNone
LanguageHaskell2010

Control.Shell.Posix

Contents

Description

Working with daemons, users, groups, file permissions and file ownerships. Not present on Windows unless shellmate is installed with the with-posix flag.

Synopsis

Users and groups

getCurrentUser :: Shell String Source #

Get the currently effective user name.

getCurrentGroups :: Shell [String] Source #

Get the list of groups associated with the current process.

getOwner :: FilePath -> Shell User Source #

Get the owner of the given file.

getGroup :: FilePath -> Shell Group Source #

Get the group of the given file.

getOwnership :: FilePath -> Shell (User, Group) Source #

Get the owner and group of the given file.

setOwner :: User -> FilePath -> Shell () Source #

Set the owner of the given file.

setGroup :: Group -> FilePath -> Shell () Source #

Set the group of the given file.

setOwnership :: User -> Group -> FilePath -> Shell () Source #

Set the owner and group of the given file.

File permissions

data CMode :: * #

Instances

Bounded CMode 
Enum CMode 
Eq CMode 

Methods

(==) :: CMode -> CMode -> Bool #

(/=) :: CMode -> CMode -> Bool #

Integral CMode 
Num CMode 
Ord CMode 

Methods

compare :: CMode -> CMode -> Ordering #

(<) :: CMode -> CMode -> Bool #

(<=) :: CMode -> CMode -> Bool #

(>) :: CMode -> CMode -> Bool #

(>=) :: CMode -> CMode -> Bool #

max :: CMode -> CMode -> CMode #

min :: CMode -> CMode -> CMode #

Read CMode 
Real CMode 

Methods

toRational :: CMode -> Rational #

Show CMode 

Methods

showsPrec :: Int -> CMode -> ShowS #

show :: CMode -> String #

showList :: [CMode] -> ShowS #

Storable CMode 

Methods

sizeOf :: CMode -> Int #

alignment :: CMode -> Int #

peekElemOff :: Ptr CMode -> Int -> IO CMode #

pokeElemOff :: Ptr CMode -> Int -> CMode -> IO () #

peekByteOff :: Ptr b -> Int -> IO CMode #

pokeByteOff :: Ptr b -> Int -> CMode -> IO () #

peek :: Ptr CMode -> IO CMode #

poke :: Ptr CMode -> CMode -> IO () #

Bits CMode 
FiniteBits CMode 

unionFileModes :: FileMode -> FileMode -> FileMode #

Combines the two file modes into one that contains modes that appear in either.

intersectFileModes :: FileMode -> FileMode -> FileMode #

Combines two file modes into one that only contains modes that appear in both.

nullFileMode :: FileMode #

No permissions.

ownerReadMode :: FileMode #

Owner has read permission.

ownerWriteMode :: FileMode #

Owner has write permission.

ownerExecuteMode :: FileMode #

Owner has execute permission.

ownerModes :: FileMode #

Owner has read, write and execute permission.

groupReadMode :: FileMode #

Group has read permission.

groupWriteMode :: FileMode #

Group has write permission.

groupExecuteMode :: FileMode #

Group has execute permission.

groupModes :: FileMode #

Group has read, write and execute permission.

otherReadMode :: FileMode #

Others have read permission.

otherWriteMode :: FileMode #

Others have write permission.

otherExecuteMode :: FileMode #

Others have execute permission.

otherModes :: FileMode #

Others have read, write and execute permission.

stdFileMode :: FileMode #

Owner, group and others have read and write permission.

accessModes :: FileMode #

Owner, group and others have read, write and execute permission.

setFileMode :: FilePath -> CMode -> Shell () Source #

Set the mode (permissions, etc.) of the given file.

getFileMode :: FilePath -> Shell CMode Source #

Get the mode of the given file.

setFileCreationMask :: CMode -> Shell CMode Source #

Set the file creation mask of this process.

Daemonizing shell computations

daemonize :: Shell () -> Shell () Source #

Daemonize a shellmate computation. This should be the last thing a computation does, as this function will terminate the parent computation. In short, daemonizing a computation involves setting the file creation mask to 0, closing standard input, output and error file descriptors, blocking sighup and changing the working directory to /.

On Windows without Cygwin, daemonize is a no-op. Consider running any program intended to be deamonized using START /B your_app, or better yet, rewriting it as a Windows service.