skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

tryposixspawnsetsid.c (562B)


      1 /* ISC license. */
      2 
      3 #undef _POSIX_C_SOURCE
      4 #undef _XOPEN_SOURCE
      5 
      6 #ifndef _XPG4_2
      7 #define _XPG4_2
      8 #endif
      9 
     10 #ifndef _GNU_SOURCE
     11 #define _GNU_SOURCE
     12 #endif
     13 
     14 #ifndef _DEFAULT_SOURCE
     15 #define _DEFAULT_SOURCE
     16 #endif
     17 
     18 #include <spawn.h>
     19 
     20 int main (void)
     21 {
     22   pid_t pid ;
     23   posix_spawn_file_actions_t actions ;
     24   posix_spawnattr_t attr ;
     25   char *const argv[2] = { "/bin/true", 0 } ;
     26   char *const envp[1] = { 0 } ;
     27   posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSID) ;
     28   posix_spawn_file_actions_init(&actions) ;
     29   return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ;
     30 }