---
name: "CREATE_SERVICE"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/CREATE_SERVICE"
---

# CREATE\_SERVICE(3)

casper service declaration macro

## NAME

**CREATE\_SERVICE** – casper service declaration macro

## LIBRARY

library “libcasper”

## SYNOPSIS

**#include \<sys/nv.h\>**

**#include \<libcasper.h\>**

**#include \<libcasper\_service.h\>**

```
typedef int service_limit_func_t(const nvlist_t *, const nvlist_t *);
typedef int service_command_func_t(const char *, const nvlist_t *, nvlist_t *,
    nvlist_t *);
```

**CREATE\_SERVICE**(*name*, *limit\_func*, *command\_func*, *flags*);

## DESCRIPTION

The **CREATE\_SERVICE** macro is used to create a new casper service. The *name* is a string containing the service name, which will be used in the [cap\_service\_open(3)](/cap_service_open/3.md), function to identify it.

The *limit\_func* is a function of type service\_limit\_func\_t where the first argument of the function contains an [nvlist(9)](/nvlist/9.md), old service limits and the second argument contains the new limits. If the service was not limited then the old limits will be set to NULL. This function must not allow the extension of service limits. The *command\_func* is a function of type service\_command\_func\_t where the first argument is the name of the command that should be executed. The first [nvlist(9)](/nvlist/9.md) contains the current limits and the second contains an [nvlist(9)](/nvlist/9.md) with the current request. The last argument contains a return value [nvlist(9)](/nvlist/9.md) which contains the response from casper.

The *flags* argument defines the limits of the service. The supported flags are:

- CASPER\_SERVICE\_STDIO

  The casper service has access to the stdio descriptors from the process it was spawned from.

- CASPER\_SERVICE\_FD

  The casper service has access to all of the descriptors, besides the stdio descriptors, from the process it was spawned from.

- CASPER\_SERVICE\_NO\_UNIQ\_LIMITS

  The whole casper communication is using an [nvlist(9)](/nvlist/9.md) with the NV\_FLAG\_NO\_UNIQUE flag.

## SEE ALSO

[cap\_enter(2)](/cap_enter/2.md), [libcasper(3)](/libcasper/3.md), [capsicum(4)](/capsicum/4.md), [nv(9)](/nv/9.md)

## HISTORY

The **libcasper** library first appeared in FreeBSD 10.3.

## AUTHORS

The **libcasper** library was implemented by Pawel Jakub Dawidek ⟨*pawel@dawidek.net*⟩ under sponsorship from the FreeBSD Foundation. The **libcasper** new architecture was implemented by Mariusz Zaborski ⟨*oshogbo@FreeBSD.org*⟩
