[asterisk-commits] mjordan: branch 1.8 r326209 - /branches/1.8/main/file.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 5 08:24:01 CDT 2011


Author: mjordan
Date: Tue Jul  5 08:23:57 2011
New Revision: 326209

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=326209
Log:
Merged revisions 325877 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r325877 | mjordan | 2011-06-30 15:09:48 -0500 (Thu, 30 Jun 2011) | 9 lines
  
  Patched voicemail user option for emailbody / emailsubject
  
  Incorporated changes per ASTERISK-16795; updated unit tests to check for vmu->emailbody / vmu->emailsubject
  
  (closes issue ASTERISK-16795)
  Reported by: mdeneen
  Tested by: mjordan
........

Modified:
    branches/1.8/main/file.c

Modified: branches/1.8/main/file.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/file.c?view=diff&rev=326209&r1=326208&r2=326209
==============================================================================
--- branches/1.8/main/file.c (original)
+++ branches/1.8/main/file.c Tue Jul  5 08:23:57 2011
@@ -29,6 +29,7 @@
 
 #include <dirent.h>
 #include <sys/stat.h>
+#include <sys/wait.h>
 #include <math.h>
 
 #include "asterisk/_private.h"	/* declare ast_file_init() */
@@ -291,6 +292,8 @@
 static void filestream_destructor(void *arg)
 {
 	struct ast_filestream *f = arg;
+	int status;
+	int pid = -1;
 
 	/* Stop a running stream if there is one */
 	if (f->owner) {
@@ -308,8 +311,14 @@
 		ast_translator_free_path(f->trans);
 
 	if (f->realfilename && f->filename) {
-		if (ast_safe_fork(0) == 0) {
+		pid = ast_safe_fork(0);
+		if (!pid) {
 			execl("/bin/mv", "mv", "-f", f->filename, f->realfilename, SENTINEL);
+			_exit(1);
+		}
+		else if (pid > 0) {
+			/* Block the parent until the move is complete.*/
+			waitpid(pid, &status, 0);
 		}
 	}
 




More information about the asterisk-commits mailing list