2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <refentry id="glib-programming">
7 <refentrytitle>Writing GLib Applications</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GLib Library</refmiscinfo>
13 <refname>Writing GLib Applications</refname>
15 General considerations when programming with GLib
20 <title>Writing GLib Applications</title>
23 <title>Threads</title>
26 The general policy of GLib is that all functions are invisibly threadsafe
27 with the exception of data structure manipulation functions, where, if
28 you have two threads manipulating the <emphasis>same</emphasis> data
29 structure, they must use a lock to synchronize their operation.
33 GLib creates a worker thread for its own purposes so GLib applications
34 will always have at least 2 threads.
38 See the sections on <link linkend="glib-Threads">threads</link> and
39 <link linkend="glib-Thread-Pools">threadpools</link> for GLib APIs that
40 support multithreaded applications.
46 <title>Security</title>
49 When writing code that runs with elevated privileges, it is important
50 to follow some basic rules of secure programming. David Wheeler has an
51 excellent book on this topic,
52 <ulink url="http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/index.html">Secure Programming for Linux and Unix HOWTO</ulink>.
56 When it comes to GLib and its associated libraries, GLib and
57 GObject are generally fine to use in code that runs with elevated
58 privileges; they don't load modules (executable code in shared objects)
59 or run other programs 'behind your back'. GIO has to be used
60 carefully in privileged programs, see the <ulink url="http://developer.gnome.org/gio/stable/ch02.html">GIO documentation</ulink> for details.