Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yad
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
Vladislav
yad
Commits
d7ded23e
Commit
d7ded23e
authored
Jan 21, 2023
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve run_command_sync for avoiding possible race conditions
parent
1d402f7d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
util.c
src/util.c
+10
-8
No files found.
src/util.c
View file @
d7ded23e
...
@@ -644,29 +644,30 @@ print_bool_val (gboolean val)
...
@@ -644,29 +644,30 @@ print_bool_val (gboolean val)
typedef
struct
{
typedef
struct
{
gchar
*
cmd
;
gchar
*
cmd
;
gchar
**
out
;
gchar
**
out
;
gint
ret
;
gboolean
lock
;
}
RunData
;
}
RunData
;
static
gboolean
run_lock
=
FALSE
;
static
gint
ret
=
0
;
static
void
static
void
run_thread
(
RunData
*
d
)
run_thread
(
RunData
*
d
)
{
{
GError
*
err
=
NULL
;
GError
*
err
=
NULL
;
if
(
!
g_spawn_command_line_sync
(
d
->
cmd
,
d
->
out
,
NULL
,
&
ret
,
&
err
))
if
(
!
g_spawn_command_line_sync
(
d
->
cmd
,
d
->
out
,
NULL
,
NULL
,
&
err
))
{
{
if
(
options
.
debug
)
if
(
options
.
debug
)
g_printerr
(
_
(
"WARNING: Run command failed: %s
\n
"
),
err
->
message
);
g_printerr
(
_
(
"WARNING: Run command failed: %s
\n
"
),
err
->
message
);
g_error_free
(
err
);
g_error_free
(
err
);
d
->
ret
=
-
1
;
}
}
run_
lock
=
FALSE
;
d
->
lock
=
FALSE
;
}
}
gint
gint
run_command_sync
(
gchar
*
cmd
,
gchar
**
out
)
run_command_sync
(
gchar
*
cmd
,
gchar
**
out
)
{
{
RunData
*
d
;
RunData
*
d
;
gint
ret
;
d
=
g_new0
(
RunData
,
1
);
d
=
g_new0
(
RunData
,
1
);
...
@@ -681,16 +682,16 @@ run_command_sync (gchar *cmd, gchar **out)
...
@@ -681,16 +682,16 @@ run_command_sync (gchar *cmd, gchar **out)
d
->
cmd
=
g_strdup
(
cmd
);
d
->
cmd
=
g_strdup
(
cmd
);
d
->
out
=
out
;
d
->
out
=
out
;
run_lock
=
TRUE
;
d
->
lock
=
TRUE
;
ret
=
0
;
g_thread_new
(
"run_sync"
,
(
GThreadFunc
)
run_thread
,
d
);
g_thread_new
(
"run_sync"
,
(
GThreadFunc
)
run_thread
,
d
);
while
(
run_
lock
!=
FALSE
)
while
(
d
->
lock
!=
FALSE
)
{
{
gtk_main_iteration_do
(
FALSE
);
gtk_main_iteration_do
(
FALSE
);
usleep
(
10000
);
usleep
(
10000
);
}
}
ret
=
d
->
ret
;
g_free
(
d
->
cmd
);
g_free
(
d
->
cmd
);
g_free
(
d
);
g_free
(
d
);
...
@@ -905,6 +906,7 @@ yad_confirm_dlg (GtkWindow *parent, gchar *txt)
...
@@ -905,6 +906,7 @@ yad_confirm_dlg (GtkWindow *parent, gchar *txt)
{
{
GtkWidget
*
d
;
GtkWidget
*
d
;
gchar
*
buf
;
gchar
*
buf
;
gint
ret
;
buf
=
g_strcompress
(
options
.
text_data
.
confirm_text
);
buf
=
g_strcompress
(
options
.
text_data
.
confirm_text
);
d
=
gtk_message_dialog_new
(
parent
,
GTK_DIALOG_DESTROY_WITH_PARENT
,
d
=
gtk_message_dialog_new
(
parent
,
GTK_DIALOG_DESTROY_WITH_PARENT
,
...
...
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