Reorgranized the script execution code to fix a race condition that
only happened in the GNOME code (as the execution of anything from the file manager in the GNOME version is done in background). Miguel.
Этот коммит содержится в:
родитель
9f508487f2
Коммит
c752ec9d97
@ -1,5 +1,8 @@
|
||||
1998-04-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* user.c (execute_menu_command): Create temporary file exclusively
|
||||
as well.
|
||||
|
||||
* main.c (do_execute), utilunix.c (my_system), gutil.c, ext.c:
|
||||
Changed the way we execute programs. Now a new set of flags exist
|
||||
that indicates how the execution is done. In ports that execute
|
||||
|
18
src/main.c
18
src/main.c
@ -707,11 +707,11 @@ restore_console (void)
|
||||
void
|
||||
exec_shell ()
|
||||
{
|
||||
do_execute (shell, 0, 1);
|
||||
do_execute (shell, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
do_execute (const char *shell, const char *command, int internal_command)
|
||||
do_execute (const char *shell, const char *command, int flags)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
char *new_dir = NULL;
|
||||
@ -732,13 +732,13 @@ do_execute (const char *shell, const char *command, int internal_command)
|
||||
#ifndef __os2__
|
||||
unlink (control_file);
|
||||
#endif
|
||||
if (!use_subshell && !internal_command){
|
||||
if (!use_subshell && !(flags & EXECUTE_INTERNAL)){
|
||||
printf ("%s%s%s\n", last_paused ? "\r\n":"", prompt, command);
|
||||
last_paused = 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (use_subshell && !internal_command){
|
||||
if (use_subshell && !(flags & EXECUTE_INTERNAL)){
|
||||
do_update_prompt ();
|
||||
|
||||
/* We don't care if it died, higher level takes care of this */
|
||||
@ -749,10 +749,10 @@ do_execute (const char *shell, const char *command, int internal_command)
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
my_system (!internal_command, shell, command);
|
||||
my_system (flags, shell, command);
|
||||
|
||||
#ifndef HAVE_GNOME
|
||||
if (!internal_command){
|
||||
if (!(flags & EXECUTE_INTERNAL)){
|
||||
if ((pause_after_run == pause_always ||
|
||||
(pause_after_run == pause_on_dumb_terminals &&
|
||||
!xterm_flag && !console_flag)) && !quit){
|
||||
@ -799,17 +799,17 @@ do_execute (const char *shell, const char *command, int internal_command)
|
||||
|
||||
/* Executes a command */
|
||||
void
|
||||
shell_execute (char *command, int internal)
|
||||
shell_execute (char *command, int flags)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (use_subshell)
|
||||
if (subshell_state == INACTIVE || force_subshell_execution)
|
||||
do_execute (shell, command, internal);
|
||||
do_execute (shell, command, flags | EXECUTE_AS_SHELL);
|
||||
else
|
||||
message (1, MSG_ERROR, _(" The shell is already running a command "));
|
||||
else
|
||||
#endif
|
||||
do_execute (shell, command, internal);
|
||||
do_execute (shell, command, flags | EXECUTE_AS_SHELL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -30,7 +30,7 @@ void do_execute (const char *shell, const char *command, int internal_command);
|
||||
#define execute_internal(command,args) do_execute (command, args, 1)
|
||||
|
||||
/* Execute functions that use the shell to execute */
|
||||
void shell_execute (char *command, int internal_command);
|
||||
void shell_execute (char *command, int flags);
|
||||
void execute (char *command);
|
||||
|
||||
/* This one executes a shell */
|
||||
@ -184,6 +184,9 @@ int do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type);
|
||||
|
||||
#endif
|
||||
|
||||
void edition_pre_exec (void);
|
||||
void edition_post_exec (void);
|
||||
|
||||
#ifdef OS2_NT
|
||||
# define MC_BASE ""
|
||||
#else
|
||||
|
@ -291,7 +291,6 @@ static int menubar_handle_key (WMenu *menubar, int key)
|
||||
const int selected = menubar->selected;
|
||||
const Menu menu = menubar->menu [selected];
|
||||
const int items = menu->count;
|
||||
char m;
|
||||
|
||||
for (i = 0; i < items; i++){
|
||||
if (!menu->entries [i].call_back)
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "mad.h"
|
||||
#include "util.h"
|
||||
#include "global.h"
|
||||
@ -491,6 +491,7 @@ void execute_menu_command (char *s)
|
||||
{
|
||||
char *commands;
|
||||
FILE *cmd_file;
|
||||
int cmd_file_fd;
|
||||
int expand_prefix_found = 0;
|
||||
int parameter_found = 0;
|
||||
int do_quote;
|
||||
@ -502,11 +503,12 @@ void execute_menu_command (char *s)
|
||||
/* OS/2 and NT requires the command to end in .cmd */
|
||||
file_name = copy_strings (file_name, ".cmd", NULL);
|
||||
#endif
|
||||
if ((cmd_file = fopen (file_name, "w+")) == NULL){
|
||||
if ((cmd_file_fd = open (file_name, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600)) == -1){
|
||||
message (1, MSG_ERROR, _(" Can't create temporary command file \n %s "),
|
||||
unix_error_string (errno));
|
||||
return;
|
||||
}
|
||||
cmd_file = fdopen (cmd_file_fd, "w");
|
||||
commands = strchr (s, '\n');
|
||||
if (!commands){
|
||||
fclose (cmd_file);
|
||||
|
@ -104,8 +104,11 @@ void close_error_pipe (int error, char *text);
|
||||
|
||||
/* Process spawning */
|
||||
void my_putenv (char*, char*);
|
||||
int my_system (int as_shell_command, const char *shell, const char *command);
|
||||
int my_system_get_child_pid (int as_shell_command, const char *shell, const char *command, pid_t *pid);
|
||||
#define EXECUTE_INTERNAL 1
|
||||
#define EXECUTE_TEMPFILE 2
|
||||
#define EXECUTE_AS_SHELL 4
|
||||
int my_system (int flags, const char *shell, const char *command);
|
||||
int my_system_get_child_pid (int flags, const char *shell, const char *command, pid_t *pid);
|
||||
void save_stop_handler (void);
|
||||
extern struct sigaction startup_handler;
|
||||
|
||||
|
@ -249,12 +249,13 @@ void save_stop_handler (void)
|
||||
#endif
|
||||
|
||||
#ifndef PORT_HAS_MY_SYSTEM
|
||||
int my_system (int as_shell_command, const char *shell, const char *command)
|
||||
int my_system (int flags, const char *shell, const char *command)
|
||||
{
|
||||
struct sigaction ignore, save_intr, save_quit, save_stop;
|
||||
pid_t pid;
|
||||
int status = 0;
|
||||
|
||||
int as_shell_command = flags & EXECUTE_AS_SHELL;
|
||||
|
||||
ignore.sa_handler = SIG_IGN;
|
||||
sigemptyset (&ignore.sa_mask);
|
||||
ignore.sa_flags = 0;
|
||||
|
@ -102,7 +102,6 @@ int max_dirt_limit =
|
||||
|
||||
/* Our callback */
|
||||
static int view_callback (Dlg_head *h, WView *view, int msg, int par);
|
||||
static void move_forward (WView *view, int i);
|
||||
|
||||
/* If set, show a ruler */
|
||||
int ruler = 0;
|
||||
|
@ -1,3 +1,8 @@
|
||||
1998-04-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* ftpfs.c (retrieve_file_start2): Open file exclusively.
|
||||
(retrieve_file): likewise.
|
||||
|
||||
1998-03-31 Philippe De Muyter <phdm@macqel.be>
|
||||
|
||||
* vfs.h: compilation fix for m68k-motorola-sysv
|
||||
|
@ -1630,7 +1630,7 @@ int retrieve_file_start(struct ftpentry *fe)
|
||||
|
||||
int retrieve_file_start2(struct ftpentry *fe)
|
||||
{
|
||||
remotelocal_handle = open(fe->local_filename, O_RDWR | O_CREAT | O_TRUNC, 0600);
|
||||
remotelocal_handle = open(fe->local_filename, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600);
|
||||
if (remotelocal_handle == -1) {
|
||||
ftpfserrno = EIO;
|
||||
free(fe->local_filename);
|
||||
@ -1749,7 +1749,7 @@ int retrieve_file(struct ftpentry *fe)
|
||||
ftpfserrno = ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
local_handle = open(fe->local_filename, O_RDWR | O_CREAT | O_TRUNC, 0600);
|
||||
local_handle = open(fe->local_filename, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600);
|
||||
if (local_handle == -1) {
|
||||
ftpfserrno = EIO;
|
||||
free(fe->local_filename);
|
||||
@ -1911,8 +1911,7 @@ _get_file_entry(struct ftpfs_connection *bucket, char *file_name,
|
||||
ftpfserrno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
handle = open(ent->local_filename, O_CREAT | O_TRUNC |
|
||||
O_RDWR, 0600);
|
||||
handle = open(ent->local_filename, O_CREAT | O_TRUNC | O_RDWR | O_EXCL, 0600);
|
||||
if (handle < 0) {
|
||||
ftpfserrno = EIO;
|
||||
return NULL;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user