More clearly define 'named menu' in the XML parser
[glib.git] / gio / inotify / inotify-diag.c
blob937ebd7029a0ebb913a8914f3f1553f79287e61f
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
3 /* inotify-helper.c - Gnome VFS Monitor based on inotify.
5 Copyright (C) 2005 John McCutchan
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.
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.
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.
22 Authors:
23 John McCutchan <john@johnmccutchan.com>
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"
34 #define DIAG_DUMP_TIME 20000 /* 20 seconds */
36 G_LOCK_EXTERN (inotify_lock);
38 static gboolean
39 id_dump (gpointer userdata)
41 GIOChannel *ioc;
42 pid_t pid;
43 char *fname;
44 G_LOCK (inotify_lock);
45 ioc = NULL;
46 pid = getpid ();
48 fname = g_strdup_printf ("/tmp/gvfsid.%d", pid);
49 ioc = g_io_channel_new_file (fname, "w", NULL);
50 g_free (fname);
52 if (!ioc)
54 G_UNLOCK (inotify_lock);
55 return TRUE;
58 _im_diag_dump (ioc);
60 g_io_channel_shutdown (ioc, TRUE, NULL);
61 g_io_channel_unref (ioc);
63 G_UNLOCK (inotify_lock);
64 return TRUE;
67 void
68 _id_startup (void)
70 if (!g_getenv ("GVFS_INOTIFY_DIAG"))
71 return;
73 g_timeout_add (DIAG_DUMP_TIME, id_dump, NULL);