mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
Bug 798250 - Gnucash permanent hang on save while loading report
Prevent WebKit's fork from getting a copy of the pipe's file descriptors and so keeping the pipe from closing. Thanks to Simon Arlott for recognizing the FD duplication.
This commit is contained in:
parent
c1525f78bc
commit
c3f8daaf7d
@ -6,7 +6,7 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14.0)
|
||||
endif()
|
||||
|
||||
project (gnucash
|
||||
VERSION 4.6
|
||||
VERSION 4.7
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
@ -1451,6 +1451,7 @@ gz_thread_func (gz_thread_params_t* params)
|
||||
}
|
||||
else if (bytes == 0)
|
||||
{
|
||||
printf("gz_thread_func EOF\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -1523,7 +1524,7 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
|
||||
return g_fopen (filename, perms);
|
||||
|
||||
{
|
||||
int filedes[2];
|
||||
int filedes[2]{};
|
||||
GThread* thread;
|
||||
gz_thread_params_t* params;
|
||||
FILE* file;
|
||||
@ -1532,10 +1533,23 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
|
||||
if (_pipe (filedes, 4096, _O_BINARY) < 0)
|
||||
{
|
||||
#else
|
||||
if (pipe (filedes) < 0)
|
||||
/* Set CLOEXEC on the pipe FDs so that if the user runs a
|
||||
* report while saving WebKit's fork won't get an open copy
|
||||
* and keep the pipe from closing. See
|
||||
* https://bugs.gnucash.org/show_bug.cgi?id=798250. Win32
|
||||
* doesn't fork nor does it support CLOEXEC.
|
||||
*/
|
||||
if (pipe (filedes) < 0 ||
|
||||
fcntl(filedes[0], F_SETFD, FD_CLOEXEC) == -1 ||
|
||||
fcntl(filedes[1], F_SETFD, FD_CLOEXEC) == -1)
|
||||
{
|
||||
#endif
|
||||
g_warning ("Pipe call failed. Opening uncompressed file.");
|
||||
g_warning ("Pipe setup failed with errno %d. Opening uncompressed file.", errno);
|
||||
if (filedes[0])
|
||||
{
|
||||
close(filedes[0]);
|
||||
close(filedes[1]);
|
||||
}
|
||||
return g_fopen (filename, perms);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user