This is used by the Makefile to extract the example program.
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
The following program demonstrates the use of some of the macros
used for dynamically allocated CPU sets.
.PP
+.\" SRC BEGIN (CPU_SET.c)
.EX
#define _GNU_SOURCE
#include <sched.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR sched_setaffinity (2),
.BR pthread_attr_setaffinity_np (3),
the result of these macros may be very different from either of the arguments.
To avoid this, ensure that both arguments have the same type.
.SH EXAMPLES
+.\" SRC BEGIN (MAX.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR fmax (3),
.BR fmin (3)
.BR __ppc_get_timebase ().
.SS Program source
\&
+.\" SRC BEGIN (__ppc_get_timebase.c)
.EX
#include <inttypes.h>
#include <stdint.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR time (2),
.BR usleep (3)
can be used within a shared library to establish functions
that are called when the shared library is unloaded.
.SH EXAMPLES
+.\" SRC BEGIN (atexit.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR _exit (2),
.BR dlopen (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (backtrace.c)
.EX
#include <execinfo.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR addr2line (1),
.BR gcc (1),
then retrieves desired elements using
.BR bsearch ().
.PP
+.\" SRC BEGIN (bsearch.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
-.\" this example referred to in qsort.3
+.\" SRC END
.SH SEE ALSO
.BR hsearch (3),
.BR lsearch (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (bswap.c)
.EX
#include <stdio.h>
#include <stdint.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR byteorder (3),
.BR endian (3)
.SH STANDARDS
C99, POSIX.1-2001, POSIX.1-2008.
.SH EXAMPLES
+.\" SRC BEGIN (cacos.c)
.EX
/* Link with "\-lm" */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR ccos (3),
.BR clog (3),
.SH STANDARDS
C99, POSIX.1-2001, POSIX.1-2008.
.SH EXAMPLES
+.\" SRC BEGIN (cacosh.c)
.EX
/* Link with "\-lm" */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR acosh (3),
.BR cabs (3),
.SH STANDARDS
C99, POSIX.1-2001, POSIX.1-2008.
.SH EXAMPLES
+.\" SRC BEGIN (catan.c)
.EX
/* Link with "\-lm" */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR ccos (3),
.BR clog (3),
.SH STANDARDS
C99, POSIX.1-2001, POSIX.1-2008.
.SH EXAMPLES
+.\" SRC BEGIN (catanh.c)
.EX
/* Link with "\-lm" */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR atanh (3),
.BR cabs (3),
to safely be removed from the list and freed from within the loop
without interfering with the traversal.
.SH EXAMPLES
+.\" SRC BEGIN (circleq.c)
.EX
#include <stddef.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR insque (3),
.BR queue (7)
.in
.SS Program source
\&
+.\" SRC BEGIN (clock_getcpuclockid.c)
.EX
#define _XOPEN_SOURCE 600
#include <stdint.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR clock_getres (2),
.BR timer_create (2),
.in
.SS Program source
\&
+.\" SRC BEGIN (dl_iterate_phdr.c)
.EX
#define _GNU_SOURCE
#include <link.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR ldd (1),
.BR objdump (1),
.in
.SS Program source
\&
+.\" SRC BEGIN (dlinfo.c)
.EX
#define _GNU_SOURCE
#include <dlfcn.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR dl_iterate_phdr (3),
.BR dladdr (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (dlopen.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR ld (1),
.BR ldd (1),
.in
.SS Program source
\&
+.\" SRC BEGIN (duplocale.c)
.EX
#define _XOPEN_SOURCE 700
#include <ctype.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR freelocale (3),
.BR newlocale (3),
.SS Features in glibc
In glibc 2.2, these functions use the DES algorithm.
.SH EXAMPLES
+.\" SRC BEGIN (encrypt.c)
.EX
#define _XOPEN_SOURCE
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR cbc_crypt (3),
.BR crypt (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (end.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR objdump (1),
.BR readelf (1),
.in
.SS Program source
\&
+.\" SRC BEGIN (endian.c)
.EX
#include <endian.h>
#include <stdint.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR bswap (3),
.BR byteorder (3)
.SH STANDARDS
These functions are a GNU extension.
.SH EXAMPLES
+.\" SRC BEGIN (envz_add.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR argz_add (3)
.in
.SS Program source
\&
+.\" SRC BEGIN (fmemopen.c)
.EX
#define _GNU_SOURCE
#include <string.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR fopen (3),
.BR fopencookie (3),
have been replaced by "pfmt() and addsev()" or by "pfmt(),
vpfmt(), lfmt(), and vlfmt()", and will be removed later.
.SH EXAMPLES
+.\" SRC BEGIN (fmtmsg.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.PP
The output should be:
.PP
closing a stream that has already been closed).
.SS Program source
\&
+.\" SRC BEGIN (fopencookie.c)
.EX
#define _GNU_SOURCE
#include <sys/types.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR fclose (3),
.BR fmemopen (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (fread.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR read (2),
.BR write (2),
.in
.SS Program source
\&
+.\" SRC BEGIN (frexp.c)
.EX
#include <math.h>
#include <float.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR ldexp (3),
.BR modf (3)
.BR nftw ().
.SS Program source
\&
+.\" SRC BEGIN (ftw.c)
.EX
#define _XOPEN_SOURCE 500
#include <ftw.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR stat (2),
.BR fts (3),
.BR get_nprocs_conf ()
can be used.
.PP
+.\" SRC BEGIN (get_nprocs_conf.c)
.EX
#include <stdlib.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR nproc (1)
.BR get_avphys_pages ()
can be used.
.PP
+.\" SRC BEGIN (get_phys_pages.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR sysconf (3)
The programs are an echo server and client for UDP datagrams.
.SS Server program
\&
+.\" SRC BEGIN (server.c)
.EX
#include <sys/types.h>
#include <stdio.h>
}
}
.EE
+.\" SRC END
.SS Client program
\&
+.\" SRC BEGIN (client.c)
.EX
#include <sys/types.h>
#include <sys/socket.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.\" .BR getipnodebyaddr (3),
.\" .BR getipnodebyname (3),
.PP
Here is the program source code
.PP
+.\" SRC BEGIN (sync.c)
.EX
#define _GNU_SOURCE
#include <netdb.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SS Asynchronous example
This example shows a simple interactive
.BR getaddrinfo_a ()
.PP
The program source is as follows:
.PP
+.\" SRC BEGIN (async.c)
.EX
#define _GNU_SOURCE
#include <netdb.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getaddrinfo (3),
.BR inet (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (getdate.c)
.EX
#define _GNU_SOURCE
#include <time.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR time (2),
.BR localtime (3),
is not really reentrant since it shares the reading position
in the stream with all other threads.
.SH EXAMPLES
+.\" SRC BEGIN (getgrent_r.c)
.EX
#define _GNU_SOURCE
#include <grp.h>
.\" printf("getgrent_r: %s", strerror(i));
.\" exit(EXIT_FAILURE);
.\" }
+.\" SRC END
.SH SEE ALSO
.BR fgetgrent (3),
.BR getgrent (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (getgrouplist.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getgroups (2),
.BR setgroups (2),
were originally GNU extensions.
They were standardized in POSIX.1-2008.
.SH EXAMPLES
+.\" SRC BEGIN (getline.c)
.EX
#define _GNU_SOURCE
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR read (2),
.BR fgets (3),
.IR "\-t val" ,
which expects an associated value.
.PP
+.\" SRC BEGIN (getopt.c)
.EX
#include <unistd.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SS getopt_long()
The following example program illustrates the use of
.BR getopt_long ()
with most of its features.
.PP
+.\" SRC BEGIN (getopt_long.c)
.EX
#include <stdio.h> /* for printf */
#include <stdlib.h> /* for exit */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getopt (1),
.BR getsubopt (3)
.in
.SS Program source
\&
+.\" SRC BEGIN (getprotoent_r.c)
.EX
#define _GNU_SOURCE
#include <ctype.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getprotoent (3),
.BR protocols (5)
is not really reentrant since it shares the reading position
in the stream with all other threads.
.SH EXAMPLES
+.\" SRC BEGIN (getpwent_r.c)
.EX
#define _GNU_SOURCE
#include <pwd.h>
.\" printf("getpwent_r: %s", strerror(i));
.\" exit(EXIT_SUCCESS);
.\" }
+.\" SRC END
.SH SEE ALSO
.BR fgetpwent (3),
.BR getpw (3),
to find the full username and user ID for the username
supplied as a command-line argument.
.PP
+.\" SRC BEGIN (getpwnam.c)
.EX
#include <pwd.h>
#include <stdint.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR endpwent (3),
.BR fgetpwent (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (getservent_r.c)
.EX
#define _GNU_SOURCE
#include <ctype.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getservent (3),
.BR services (5)
.SH EXAMPLES
The following program expects suboptions following a "\-o" option.
.PP
+.\" SRC BEGIN (getsubopt.c)
.EX
#define _XOPEN_SOURCE 500
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getopt (3)
and
.BR ttyname (3).
.PP
+.\" SRC BEGIN (getutent.c)
.EX
#include <string.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getutmp (3),
.BR utmp (5)
.in
.SS Program source
\&
+.\" SRC BEGIN (gnu_get_libc_version.c)
.EX
#include <gnu/libc\-version.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR confstr (3)
The following program inserts 24 items into a hash table, then prints
some of them.
.PP
+.\" SRC BEGIN (hsearch.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR bsearch (3),
.BR lsearch (3),
.EE
.in
.SS Program source
+.\" SRC BEGIN (if_nameindex.c)
.EX
#include <net/if.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getsockopt (2),
.BR setsockopt (2),
.in
.SS Program source
\&
+.\" SRC BEGIN (inet.c)
.EX
#define _DEFAULT_SOURCE
#include <arpa/inet.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR byteorder (3),
.BR getaddrinfo (3),
.EE
.in
.SS Program source
+.\" SRC BEGIN (inet_net_pton.c)
.EX
/* Link with "\-lresolv" */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR inet (3),
.BR networks (5)
.in
.SS Program source
\&
+.\" SRC BEGIN (inet_pton.c)
.EX
#include <arpa/inet.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getaddrinfo (3),
.BR inet (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (insque.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR queue (7)
to safely be removed from the list and freed from within the loop
without interfering with the traversal.
.SH EXAMPLES
+.\" SRC BEGIN (list.c)
.EX
#include <stddef.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR insque (3),
.BR queue (7)
.in
.SS Program source
\&
+.\" SRC BEGIN (makecontext.c)
.EX
#include <ucontext.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR sigaction (2),
.BR sigaltstack (2),
.in
.SS Program source
\&
+.\" SRC BEGIN (mallinfo.c)
.EX
#include <malloc.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.EE
.in
.SS Program source
+.\" SRC BEGIN (malloc_info.c)
.EX
#include <unistd.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR mallinfo (3),
.BR malloc (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (mallopt.c)
.EX
#include <malloc.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.in
.SS Program source
\&
+.\" SRC BEGIN (matherr.c)
.EX
#define _SVID_SOURCE
#include <errno.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR fenv (3),
.BR math_error (7),
.in
.SS Program source
\&
+.\" SRC BEGIN (mbstowcs.c)
.EX
#include <wctype.h>
#include <locale.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR mblen (3),
.BR mbsrtowcs (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (mcheck.c)
.EX
#include <stdlib.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR malloc (3),
.BR mallopt (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (mq_getattr.c)
.EX
#include <mqueue.h>
#include <sys/stat.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR mq_close (3),
.BR mq_notify (3),
The thread executes a function which reads one message from the
queue and then terminates the process.
.SS Program source
+.\" SRC BEGIN (mq_notify.c)
.EX
#include <pthread.h>
#include <mqueue.h>
pause(); /* Process will be terminated by thread function */
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR mq_close (3),
.BR mq_getattr (3),
The demonstration uses the following program:
.PP
.in +4n
-.EX
.RB "$ " "cat t_mtrace.c"
+.\" SRC BEGIN (t_mtrace.c)
+.EX
#include <mcheck.h>
#include <stdlib.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.in
.PP
When we run the program as follows, we see that
.EE
.in
.SS Program source
+.\" SRC BEGIN (newlocale.c)
.EX
#define _XOPEN_SOURCE 700
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR locale (1),
.BR duplocale (3),
according to the environment and queries the terminal character set and
the radix character.
.PP
+.\" SRC BEGIN (nl_langinfo.c)
.EX
#include <langinfo.h>
#include <locale.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR locale (1),
.BR localeconv (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (offsetof.c)
.EX
#include <stddef.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.in
.SS Program source
\&
+.\" SRC BEGIN (posix_spawn.c)
.EX
#include <spawn.h>
#include <stdint.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.nh \" Disable hyphenation
.ad l
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_attr_init.c)
.EX
#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */
#include <pthread.h>
pause(); /* Terminates when other thread calls exit() */
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_cancel.c)
.EX
#include <pthread.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
was nonzero.
.SS Program source
\&
+.\" SRC BEGIN (pthread_cleanup_push.c)
.EX
#include <pthread.h>
#include <sys/types.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR pthread_cancel (3),
.BR pthread_cleanup_push_defer_np (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_create.c)
.EX
#include <pthread.h>
#include <string.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_getattr_default_np.c)
.EX
#define _GNU_SOURCE
#include <pthread.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_getattr_np.c)
.EX
#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */
#include <pthread.h>
pause(); /* Terminates when other thread calls exit() */
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_getcpuclockid.c)
.EX
/* Link with "\-lrt" */
exit(EXIT_SUCCESS); /* Terminates both threads */
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR clock_gettime (2),
.BR clock_settime (2),
.EE
.in
.SS Program source
+.\" SRC BEGIN (pthread_mutexattr_setrobust.c)
.EX
#include <stdlib.h>
#include <stdio.h>
}
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.BR pthread_getaffinity_np ()
to check the resulting CPU affinity mask of the thread.
.PP
+.\" SRC BEGIN (pthread_setaffinity_np.c)
.EX
#define _GNU_SOURCE
#include <pthread.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR sched_setaffinity (2),
.BR CPU_SET (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_setname_np.c)
.EX
#define _GNU_SOURCE
#include <pthread.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
is the default for the inherit scheduler attribute.
.SS Program source
\&
+.\" SRC BEGIN (pthreads_sched_test.c)
.EX
/* pthreads_sched_test.c */
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.ad l
.nh
.in
.SS Program source
\&
+.\" SRC BEGIN (pthread_sigmask.c)
.EX
#include <pthread.h>
#include <stdio.h>
pause(); /* Dummy pause so we can test program */
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR sigaction (2),
.BR sigpending (2),
Another example is the following program,
which sorts the strings given in its command-line arguments:
.PP
+.\" SRC BEGIN (qsort.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR sort (1),
.BR alphasort (3),
when given a particular seed.
.PP
.in +4n
+.\" SRC BEGIN (rand.c)
.EX
#include <stdlib.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.in
.SH SEE ALSO
.BR drand48 (3),
.BR rpmatch ()
is applied to the string given in the program's command-line argument.
.PP
+.\" SRC BEGIN (rpmatch.c)
.EX
#define _SVID_SOURCE
#include <locale.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR fgets (3),
.BR getline (3),
Using "localhost" does not work.
The result is the localtime of the computer "linux".
.PP
+.\" SRC BEGIN (rtime.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.\" .BR netdate (1),
.BR ntpdate (1),
.\"
.SS Program source
\&
+.\" SRC BEGIN (scandir.c)
.EX
#define _DEFAULT_SOURCE
#include <dirent.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR closedir (3),
.BR fnmatch (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (sem_wait.c)
.EX
#include <unistd.h>
#include <stdio.h>
exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR clock_gettime (2),
.BR sem_getvalue (3),
.IR "gcc example.c \-o example" .
It will dump all names in the alias database.
.PP
+.\" SRC BEGIN (setaliasent.c)
.EX
#include <aliases.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR getgrent (3),
.BR getpwent (3),
is closed, which also happens at program termination.
For example, the following is invalid:
.PP
+.\" SRC BEGIN (setbuf.c)
.EX
#include <stdio.h>
return 0;
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR stdbuf (1),
.BR fclose (3),
on the memory object that is shared between the two programs.
.PP
.in +4n
+.\" SRC BEGIN (pshm_ucase.h)
.EX
#include <sys/mman.h>
#include <fcntl.h>
char buf[BUF_SIZE]; /* Data being transferred */
};
.EE
+.\" SRC END
.in
.\"
.SS Program source: pshm_ucase_bounce.c
to tell the "send" program that it may now access the shared memory.
.PP
.in +4n
+.\" SRC BEGIN (pshm_ucase_bounce.c)
.EX
/* pshm_ucase_bounce.c
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.in
.\"
.SS Program source: pshm_ucase_send.c
on standard output.
.PP
.in +4n
+.\" SRC BEGIN (pshm_ucase_send.c)
.EX
/* pshm_ucase_send.c
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.in
.SH SEE ALSO
.BR close (2),
to safely be removed from the list and freed from within the loop
without interfering with the traversal.
.SH EXAMPLES
+.\" SRC BEGIN (slist.c)
.EX
#include <stddef.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR insque (3),
.BR queue (7)
to safely be removed from the list and freed from within the loop
without interfering with the traversal.
.SH EXAMPLES
+.\" SRC BEGIN (stailq.c)
.EX
#include <stddef.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR insque (3),
.BR queue (7)
.BR foobar ,
which it then prints.
.PP
+.\" SRC BEGIN (stpcpy.c)
.EX
#define _GNU_SOURCE
#include <string.h>
printf("%s\en", buffer);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR bcopy (3),
.BR memccpy (3),
.\"
.SS Program source
\&
+.\" SRC BEGIN (strcat.c)
.EX
#include <stdint.h>
#include <string.h>
}
}
.EE
-.\"
+.\" SRC END
.SH SEE ALSO
.BR bcopy (3),
.BR memccpy (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (string_comp.c)
.EX
/* string_comp.c
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR bcmp (3),
.BR memcmp (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (strftime.c)
.EX
#include <time.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR date (1),
.BR time (2),
and
.BR strftime (3).
.PP
+.\" SRC BEGIN (strptime.c)
.EX
#define _XOPEN_SOURCE
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR time (2),
.BR getdate (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (strsep.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR index (3),
.BR memchr (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (strtok.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.PP
Another example program using
.BR strtok ()
.in
.SS Program source
\&
+.\" SRC BEGIN (strtol.c)
.EX
#include <stdlib.h>
#include <limits.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR atof (3),
.BR atoi (3),
.in
.SS Program source
\&
+.\" SRC BEGIN (strverscmp.c)
.EX
#define _GNU_SOURCE
#include <string.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR rename (1),
.BR strcasecmp (3),
to safely be removed from the list and freed from within the loop
without interfering with the traversal.
.SH EXAMPLES
+.\" SRC BEGIN (tailq.c)
.EX
#include <stddef.h>
#include <stdio.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR insque (3),
.BR queue (7)
tree, where duplicate numbers are collapsed, then prints the numbers
in order.
.PP
+.\" SRC BEGIN (tsearch.c)
.EX
#define _GNU_SOURCE /* Expose declaration of tdestroy() */
#include <search.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR bsearch (3),
.BR hsearch (3),
The output of the following example program
is approximately that of "ls [a-c]*.c".
.PP
+.\" SRC BEGIN (wordexp.c)
.EX
#include <stdio.h>
#include <stdlib.h>
exit(EXIT_SUCCESS);
}
.EE
+.\" SRC END
.SH SEE ALSO
.BR fnmatch (3),
.BR glob (3)