Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
7bfda497
Commit
7bfda497
authored
Dec 02, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up temp files also when killed by a signal.
parent
505dfdef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
main.c
tools/winebuild/main.c
+10
-0
winegcc.c
tools/winegcc/winegcc.c
+23
-2
No files found.
tools/winebuild/main.c
View file @
7bfda497
...
...
@@ -27,6 +27,7 @@
#include <assert.h>
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
...
...
@@ -128,6 +129,11 @@ static void cleanup(void)
if
(
output_file_name
)
unlink
(
output_file_name
);
}
/* clean things up when aborting on a signal */
static
void
exit_on_signal
(
int
sig
)
{
exit
(
1
);
/* this will call atexit functions */
}
/*******************************************************************
* command-line option handling
...
...
@@ -415,6 +421,10 @@ int main(int argc, char **argv)
{
DLLSPEC
*
spec
=
alloc_dll_spec
();
signal
(
SIGHUP
,
exit_on_signal
);
signal
(
SIGTERM
,
exit_on_signal
);
signal
(
SIGINT
,
exit_on_signal
);
output_file
=
stdout
;
argv
=
parse_options
(
argc
,
argv
,
spec
);
...
...
tools/winegcc/winegcc.c
View file @
7bfda497
...
...
@@ -90,6 +90,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
...
...
@@ -137,6 +138,7 @@ static const char* app_loader_template =
static
int
keep_generated
=
0
;
static
strarray
*
tmp_files
;
static
sigset_t
signal_mask
;
struct
options
{
...
...
@@ -169,10 +171,21 @@ static void clean_temp_files()
unlink
(
tmp_files
->
base
[
i
]);
}
/* clean things up when aborting on a signal */
static
void
exit_on_signal
(
int
sig
)
{
exit
(
1
);
/* this will call the atexit functions */
}
char
*
get_temp_file
(
const
char
*
prefix
,
const
char
*
suffix
)
{
int
fd
;
sigset_t
old_set
;
char
*
tmp
=
strmake
(
"%s-XXXXXX%s"
,
prefix
,
suffix
);
int
fd
=
mkstemps
(
tmp
,
strlen
(
suffix
)
);
/* block signals while manipulating the temp files list */
sigprocmask
(
SIG_BLOCK
,
&
signal_mask
,
&
old_set
);
fd
=
mkstemps
(
tmp
,
strlen
(
suffix
)
);
if
(
fd
==
-
1
)
{
/* could not create it in current directory, try in /tmp */
...
...
@@ -183,7 +196,7 @@ char* get_temp_file(const char* prefix, const char* suffix)
}
close
(
fd
);
strarray_add
(
tmp_files
,
tmp
);
sigprocmask
(
SIG_SETMASK
,
&
old_set
,
NULL
);
return
tmp
;
}
...
...
@@ -687,6 +700,14 @@ int main(int argc, char **argv)
char
*
lang
=
0
;
char
*
str
;
signal
(
SIGHUP
,
exit_on_signal
);
signal
(
SIGTERM
,
exit_on_signal
);
signal
(
SIGINT
,
exit_on_signal
);
sigemptyset
(
&
signal_mask
);
sigaddset
(
&
signal_mask
,
SIGHUP
);
sigaddset
(
&
signal_mask
,
SIGTERM
);
sigaddset
(
&
signal_mask
,
SIGINT
);
/* setup tmp file removal at exit */
tmp_files
=
strarray_alloc
();
atexit
(
clean_temp_files
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment