Home | History | Annotate | Line # | Download | only in c
      1 /* Check error message for invalid sysctl call.
      2 #xerror:
      3 #output: Unimplemented _sysctl syscall *\n
      4 #output: program stopped with signal 4 (*).\n
      5 #progos: linux
      6 */
      7 
      8 #include <unistd.h>
      9 #include <sys/syscall.h>
     10 #include <errno.h>
     11 #include <stdio.h>
     12 #include <stdlib.h>
     13 #include <errno.h>
     14 
     15 int main (void)
     16 {
     17   static int sysctl_args[] = { 99, 99 };
     18   size_t x = 8;
     19 
     20   struct __sysctl_args {
     21     int *name;
     22     int nlen;
     23     void *oldval;
     24     size_t *oldlenp;
     25     void *newval;
     26     size_t newlen;
     27     unsigned long __unused[4];
     28   } scargs
     29       =
     30    {
     31      sysctl_args,
     32      sizeof (sysctl_args) / sizeof (sysctl_args[0]),
     33      (void *) -1, &x, NULL, 0
     34    };
     35 
     36   int err = syscall (SYS__sysctl, &scargs);
     37   if (err == -1 && errno == ENOSYS)
     38     printf ("ENOSYS\n");
     39  printf ("xyzzy\n");
     40  exit (0);
     41 }
     42