[systemd-devel] systemd-activation: it's a mess for beginners

Mantas Mikulėnas grawity at gmail.com
Wed Mar 20 19:52:16 UTC 2019


On Wed, Mar 20, 2019 at 9:46 PM Reindl Harald <h.reindl at thelounge.net> wrote:
>
> http://0pointer.de/blog/projects/socket-activation.html
>
> ---------------------------------------------
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
> #include <stdio.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <unistd.h>
> #include <string.h>
> #include <stdlib.h>
> #include </usr/include/systemd/sd-daemon.h>
>
> int fd;
>
> if(sd_listen_fds(0) != 1)
> {
>  fprintf(stderr, "No or too many file descriptors received.\n");
>  exit(1);
> }
>
> fd = SD_LISTEN_FDS_START + 0;
>
> ---------------------------------------------
>
> demo-udp.c:16:1: error: expected identifier or '(' before 'if'
>  if(sd_listen_fds(0) != 1)
>  ^~
> demo-udp.c:22:1: warning: data definition has no type or storage class
>  fd = SD_LISTEN_FDS_START + 0;
>  ^~
> demo-udp.c:22:1: warning: type defaults to 'int' in declaration of 'fd'
> [-Wimplicit-int]
>
> ---------------------------------------------

I think you got the wrong mailing list; the requirement to put the
code inside a main() function is a basic feature of C syntax and is
not part of systemd.

-- 
Mantas Mikulėnas


More information about the systemd-devel mailing list