Improve the g_file_make_symbolic_link docs
[platform/upstream/glib.git] / gio / inotify / inotify-diag.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
2
3 /* inotify-helper.c - Gnome VFS Monitor based on inotify.
4
5    Copyright (C) 2005 John McCutchan
6
7    The Gnome Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11
12    The Gnome Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16
17    You should have received a copy of the GNU Library General Public
18    License along with the Gnome Library; see the file COPYING.LIB.  If not,
19    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.
21
22    Authors: 
23                  John McCutchan <john@johnmccutchan.com>
24 */
25
26 #include "config.h"
27 #include <glib.h>
28 #include <sys/types.h>
29 #include <unistd.h>
30 #include "inotify-missing.h"
31 #include "inotify-path.h"
32 #include "inotify-diag.h"
33
34 #define DIAG_DUMP_TIME 20000 /* 20 seconds */
35
36 G_LOCK_EXTERN (inotify_lock);
37
38 static gboolean
39 id_dump (gpointer userdata)
40 {
41   GIOChannel *ioc;
42   pid_t pid;
43   char *fname;
44   G_LOCK (inotify_lock);
45   ioc = NULL;
46   pid = getpid ();
47
48   fname = g_strdup_printf ("/tmp/gvfsid.%d", pid);
49   ioc = g_io_channel_new_file (fname, "w", NULL);
50   g_free (fname);
51   
52   if (!ioc)
53     {
54       G_UNLOCK (inotify_lock);
55       return TRUE;
56     }
57
58   _im_diag_dump (ioc);
59   
60   g_io_channel_shutdown (ioc, TRUE, NULL);
61   g_io_channel_unref (ioc);
62   
63   G_UNLOCK (inotify_lock);
64   return TRUE;
65 }
66
67 void
68 _id_startup (void)
69 {
70   if (!g_getenv ("GVFS_INOTIFY_DIAG"))
71     return;
72         
73   g_timeout_add (DIAG_DUMP_TIME, id_dump, NULL);
74 }