- fprintf( file, "\xEF\xBB\xBF###\n### " COPYRIGHT_MESSAGE "\n###\n\n"
- "###\n### lines beginning with a '#' character are comments\n###\n\n" );
+ /* Configuration lock must be taken before vlcrc serializer below. */
+ vlc_rwlock_rdlock (&config_lock);
+
+ /* The temporary configuration file is per-PID. Therefore SaveConfigFile()
+ * should be serialized against itself within a given process. */
+ static vlc_mutex_t lock = VLC_STATIC_MUTEX;
+ vlc_mutex_lock (&lock);
+
+ int fd = vlc_open (temporary, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR);
+ if (fd == -1)
+ {
+ vlc_rwlock_unlock (&config_lock);
+ vlc_mutex_unlock (&lock);
+ module_list_free (list);
+ goto error;
+ }
+ file = fdopen (fd, "wt");
+ if (file == NULL)
+ {
+ vlc_rwlock_unlock (&config_lock);
+ close (fd);
+ vlc_mutex_unlock (&lock);
+ module_list_free (list);
+ goto error;
+ }
+
+ fprintf( file,
+ "\xEF\xBB\xBF###\n"
+ "### "PACKAGE_NAME" "PACKAGE_VERSION"\n"
+ "###\n"
+ "\n"
+ "###\n"
+ "### lines beginning with a '#' character are comments\n"
+ "###\n"
+ "\n" );