This commit is contained in:
Miguel de Icaza 1998-04-23 19:31:32 +00:00
parent 301a9f4846
commit 9f508487f2
6 changed files with 125 additions and 94 deletions

View File

@ -31,7 +31,7 @@
#define PORT_WIDGET_WANTS_HISTORY 0
#define PORT_HAS_UPDATE_MARKS 1
#define PORT_HAS_RADIO_TOGGLE 1
#define PORT_DOES_BACKGROUND_EXEC 1
#define mi_getch() fprintf (stderr, "mi_getch is not implemented in this port\n")
#define frontend_run_dlg(x) gtkrundlg_event (x)

View File

@ -49,7 +49,7 @@
#include <gdk/gdkprivate.h>
#include "util.h"
int my_system_get_child_pid (int as_shell_command, const char *shell, const char *command, pid_t *pid)
int my_system_get_child_pid (int flags, const char *shell, const char *command, pid_t *pid)
{
struct sigaction ignore, save_intr, save_quit, save_stop;
int status = 0, i;
@ -73,12 +73,26 @@ int my_system_get_child_pid (int as_shell_command, const char *shell, const char
for (i = 3; i < top; i++)
close (i);
if (as_shell_command)
*pid = fork ();
if (*pid == 0){
if (flags & EXECUTE_AS_SHELL)
execl (shell, shell, "-c", command, (char *) 0);
else
execlp (shell, shell, command, (char *) 0);
/* See note below for why we use _exit () */
_exit (127); /* Exec error */
} else {
int status;
waitpid (*pid, &status, 0);
if (flags & EXECUTE_TEMPFILE)
unlink (command);
}
/* We need to use _exit instead of exit to avoid
* calling the atexit handlers (specifically the gdk atexit
* handler
*/
_exit (0);
}
sigaction (SIGINT, &save_intr, NULL);
sigaction (SIGQUIT, &save_quit, NULL);
@ -91,11 +105,11 @@ int my_system_get_child_pid (int as_shell_command, const char *shell, const char
return WEXITSTATUS(status);
}
int my_system (int as_shell_command, const char *shell, const char *command)
int my_system (int flags, const char *shell, const char *command)
{
pid_t pid;
return my_system_get_child_pid (as_shell_command, shell, command, &pid);
return my_system_get_child_pid (flags, shell, command, &pid);
}
int

130
po/mc.pot
View File

@ -1,6 +1,6 @@
msgid ""
msgstr ""
"Date: 1998-04-22 01:04:36-0500\n"
"Date: 1998-04-23 14:33:00-0500\n"
"From: Miguel de Icaza,computo,622-4680 <miguel@metropolis.nuclecu.unam.mx>\n"
"Content-Type: text/plain; charset=\n"
"Xgettext-Options: --default-domain=mc --directory=.. --add-comments --keyword=_ --keyword=N_ --files-from=./POTFILES.in\n"
@ -63,7 +63,7 @@ msgid " Save As "
msgstr ""
#. Warning message with a query to continue or cancel the operation
#: edit/editcmd.c:407 edit/editcmd.c:714 edit/editcmd.c:726 edit/editcmd.c:827 edit/editcmd.c:910 gnome/gdesktop.c:1256 src/ext.c:291 src/help.c:320 src/main.c:683 src/subshell.c:696 src/subshell.c:722 src/utilunix.c:373 src/utilunix.c:377 src/utilunix.c:443
#: edit/editcmd.c:407 edit/editcmd.c:714 edit/editcmd.c:726 edit/editcmd.c:827 edit/editcmd.c:910 gnome/gdesktop.c:1258 src/ext.c:295 src/help.c:320 src/main.c:683 src/subshell.c:696 src/subshell.c:722 src/utilunix.c:374 src/utilunix.c:378 src/utilunix.c:444
msgid " Warning "
msgstr ""
@ -141,7 +141,7 @@ msgstr ""
msgid " Save file "
msgstr ""
#: edit/editcmd.c:687 edit/editwidget.c:911 src/view.c:1983
#: edit/editcmd.c:687 edit/editwidget.c:911 src/view.c:1982
msgid "Save"
msgstr ""
@ -186,7 +186,7 @@ msgid " Replace "
msgstr ""
#. Heads the 'Search' dialog box
#: edit/editcmd.c:1111 edit/editcmd.c:1287 edit/editcmd.c:1943 src/view.c:1470 src/view.c:1560 src/view.c:1682 src/view.c:1878 src/view.c:1910
#: edit/editcmd.c:1111 edit/editcmd.c:1287 edit/editcmd.c:1943 src/view.c:1469 src/view.c:1559 src/view.c:1681 src/view.c:1877 src/view.c:1909
msgid " Search "
msgstr ""
@ -304,11 +304,11 @@ msgstr ""
msgid "Cancel quit"
msgstr ""
#: edit/editcmd.c:1961 gnome/gcmd.c:94 gnome/gdesktop.c:1071 src/cmd.c:241 src/file.c:2116 src/file.c:2469 src/file.c:2549 src/hotlist.c:1027 src/main.c:838 src/screen.c:1983 src/subshell.c:697 src/subshell.c:723 src/tree.c:1195 src/view.c:411
#: edit/editcmd.c:1961 gnome/gcmd.c:94 gnome/gdesktop.c:1073 src/cmd.c:241 src/file.c:2116 src/file.c:2469 src/file.c:2549 src/hotlist.c:1027 src/main.c:838 src/screen.c:1983 src/subshell.c:697 src/subshell.c:723 src/tree.c:1195 src/view.c:410
msgid "&Yes"
msgstr ""
#: edit/editcmd.c:1961 gnome/gcmd.c:94 gnome/gdesktop.c:1071 src/cmd.c:241 src/file.c:2116 src/file.c:2466 src/file.c:2549 src/hotlist.c:1027 src/main.c:838 src/screen.c:1983 src/subshell.c:697 src/subshell.c:723 src/tree.c:1195 src/view.c:411
#: edit/editcmd.c:1961 gnome/gcmd.c:94 gnome/gdesktop.c:1073 src/cmd.c:241 src/file.c:2116 src/file.c:2466 src/file.c:2549 src/hotlist.c:1027 src/main.c:838 src/screen.c:1983 src/subshell.c:697 src/subshell.c:723 src/tree.c:1195 src/view.c:410
msgid "&No"
msgstr ""
@ -342,7 +342,7 @@ msgstr ""
msgid " Cut to clipboard "
msgstr ""
#: edit/editcmd.c:2220 edit/editcmd.c:2222 src/view.c:1851
#: edit/editcmd.c:2220 edit/editcmd.c:2222 src/view.c:1850
msgid " Goto line "
msgstr ""
@ -753,7 +753,7 @@ msgstr ""
msgid "Error initialising editor.\n"
msgstr ""
#: edit/editwidget.c:910 gnome/glayout.c:358 src/help.c:812 src/main.c:1670 src/screen.c:2194 src/screen.c:2228 src/tree.c:1451 src/view.c:1978
#: edit/editwidget.c:910 gnome/glayout.c:358 src/help.c:812 src/main.c:1670 src/screen.c:2194 src/screen.c:2228 src/tree.c:1451 src/view.c:1977
msgid "Help"
msgstr ""
@ -773,11 +773,11 @@ msgstr ""
msgid "Move"
msgstr ""
#: edit/editwidget.c:916 gnome/gview.c:291 gnome/gview.c:315 src/view.c:1991
#: edit/editwidget.c:916 gnome/gview.c:291 gnome/gview.c:315 src/view.c:1990
msgid "Search"
msgstr ""
#: edit/editwidget.c:917 gnome/gdesktop.c:968 gnome/glayout.c:282 src/screen.c:2201 src/screen.c:2235
#: edit/editwidget.c:917 gnome/gdesktop.c:970 gnome/glayout.c:282 src/screen.c:2201 src/screen.c:2235
msgid "Delete"
msgstr ""
@ -785,7 +785,7 @@ msgstr ""
msgid "PullDn"
msgstr ""
#: edit/editwidget.c:920 gnome/gview.c:286 src/help.c:824 src/main.c:1673 src/view.c:1980 src/view.c:2000
#: edit/editwidget.c:920 gnome/gview.c:286 src/help.c:824 src/main.c:1673 src/view.c:1979 src/view.c:1999
msgid "Quit"
msgstr ""
@ -805,7 +805,7 @@ msgid ""
"\n"
msgstr ""
#: src/achown.c:72 src/boxes.c:139 src/boxes.c:274 src/boxes.c:371 src/boxes.c:458 src/boxes.c:637 src/boxes.c:758 src/boxes.c:800 src/chmod.c:115 src/chown.c:81 src/cmd.c:833 src/file.c:1953 src/find.c:158 src/hotlist.c:140 src/hotlist.c:810 src/hotlist.c:903 src/layout.c:365 src/learn.c:58 src/option.c:143 src/panelize.c:89 src/view.c:411 src/wtools.c:114 src/wtools.c:408 src/wtools.c:581 src/wtools.c:661
#: src/achown.c:72 src/boxes.c:139 src/boxes.c:274 src/boxes.c:371 src/boxes.c:458 src/boxes.c:637 src/boxes.c:758 src/boxes.c:800 src/chmod.c:115 src/chown.c:81 src/cmd.c:833 src/file.c:1953 src/find.c:158 src/hotlist.c:140 src/hotlist.c:810 src/hotlist.c:903 src/layout.c:365 src/learn.c:58 src/option.c:143 src/panelize.c:89 src/view.c:410 src/wtools.c:114 src/wtools.c:408 src/wtools.c:581 src/wtools.c:661
msgid "&Cancel"
msgstr ""
@ -1525,50 +1525,50 @@ msgstr ""
msgid "Unknown"
msgstr ""
#: src/ext.c:137 src/user.c:506
#: src/ext.c:139 src/user.c:506
msgid ""
" Can't create temporary command file \n"
" %s "
msgstr ""
#: src/ext.c:147 src/user.c:532
#: src/ext.c:152 src/user.c:532
msgid " Parameter "
msgstr ""
#: src/ext.c:291
#: src/ext.c:295
msgid " Can't execute commands on a Virtual File System directory "
msgstr ""
#: src/ext.c:386
#: src/ext.c:392
msgid " file error"
msgstr ""
#: src/ext.c:387
#: src/ext.c:393
msgid "Format of the "
msgstr ""
#: src/ext.c:405
#: src/ext.c:411
msgid " file error "
msgstr ""
#: src/ext.c:406
#: src/ext.c:412
msgid "Format of the ~/"
msgstr ""
#: src/ext.c:406
#: src/ext.c:412
msgid ""
" file has changed\n"
"with version 3.0. You may want either to\n"
"copy it from "
msgstr ""
#: src/ext.c:408
#: src/ext.c:414
msgid ""
"mc.ext or use that\n"
"file as an example of how to write it.\n"
msgstr ""
#: src/ext.c:410
#: src/ext.c:416
msgid "mc.ext will be used for this moment."
msgstr ""
@ -2056,7 +2056,7 @@ msgstr ""
msgid "Finished"
msgstr ""
#: src/find.c:526 src/view.c:1470
#: src/find.c:526 src/view.c:1469
msgid "Searching %s"
msgstr ""
@ -2539,7 +2539,7 @@ msgstr ""
msgid " The shell is already running a command "
msgstr ""
#: gnome/gcmd.c:92 gnome/gdesktop.c:1069 src/main.c:836 src/screen.c:1981
#: gnome/gcmd.c:92 gnome/gdesktop.c:1071 src/main.c:836 src/screen.c:1981
msgid " The Midnight Commander "
msgstr ""
@ -3142,7 +3142,7 @@ msgstr ""
msgid "Unknow tag on display format: "
msgstr ""
#: gnome/gdesktop.c:1070 src/screen.c:1982
#: gnome/gdesktop.c:1072 src/screen.c:1982
msgid " Do you really want to execute? "
msgstr ""
@ -3150,7 +3150,7 @@ msgstr ""
msgid "View"
msgstr ""
#: src/screen.c:2197 src/screen.c:2231 src/view.c:1987
#: src/screen.c:2197 src/screen.c:2231 src/view.c:1986
msgid "Edit"
msgstr ""
@ -3292,153 +3292,153 @@ msgstr ""
msgid "name_trunc: too big"
msgstr ""
#: src/utilunix.c:373
#: src/utilunix.c:374
msgid " Pipe failed "
msgstr ""
#: src/utilunix.c:377
#: src/utilunix.c:378
msgid " Dup failed "
msgstr ""
#: src/view.c:408
#: src/view.c:407
msgid ""
"File: \n"
"\n"
" "
msgstr ""
#: src/view.c:409
#: src/view.c:408
msgid ""
"\n"
"\n"
"has been modified, do you want to save the changes?\n"
msgstr ""
#: src/view.c:411
#: src/view.c:410
msgid " Save changes "
msgstr ""
#: src/view.c:453
#: src/view.c:452
msgid " Can't spawn child program "
msgstr ""
#: src/view.c:463
#: src/view.c:462
msgid " Empty output from child filter "
msgstr ""
#: src/view.c:469
#: src/view.c:468
msgid " Could not open file "
msgstr ""
#: src/view.c:487
#: src/view.c:486
msgid " Can't open file \""
msgstr ""
#: src/view.c:495
#: src/view.c:494
msgid ""
" Can't stat file \n"
" "
msgstr ""
#: src/view.c:501
#: src/view.c:500
msgid " Can't view: not a regular file "
msgstr ""
#: src/view.c:521
#: src/view.c:520
msgid " Can not fetch local copy "
msgstr ""
#: src/view.c:704
#: src/view.c:703
msgid "File: %s"
msgstr ""
#: gnome/gview.c:119 src/view.c:709
#: gnome/gview.c:119 src/view.c:708
msgid "Offset 0x%08x"
msgstr ""
#: gnome/gview.c:121 src/view.c:711
#: gnome/gview.c:121 src/view.c:710
msgid "Col %d"
msgstr ""
#: gnome/gview.c:125 src/view.c:715
#: gnome/gview.c:125 src/view.c:714
msgid "%s bytes"
msgstr ""
#: src/view.c:720
#: src/view.c:719
msgid " [grow]"
msgstr ""
#: src/view.c:1560 src/view.c:1682
#: src/view.c:1559 src/view.c:1681
msgid " Search string not found "
msgstr ""
#: src/view.c:1721
#: src/view.c:1720
msgid " Invalid regular expression "
msgstr ""
#: src/view.c:1849
#: src/view.c:1848
msgid ""
" The current line number is %d.\n"
" Enter the new line number:"
msgstr ""
#: src/view.c:1878
#: src/view.c:1877
msgid " Enter regexp:"
msgstr ""
#: src/view.c:1910
#: src/view.c:1909
msgid " Enter search string:"
msgstr ""
#: src/view.c:1981
#: src/view.c:1980
msgid "Ascii"
msgstr ""
#: gnome/gview.c:308 src/view.c:1981
#: gnome/gview.c:308 src/view.c:1980
msgid "Hex"
msgstr ""
#: src/view.c:1982
#: src/view.c:1981
msgid "Line"
msgstr ""
#: src/view.c:1983
#: src/view.c:1982
msgid "RxSrch"
msgstr ""
#: src/view.c:1986
#: src/view.c:1985
msgid "EdText"
msgstr ""
#: src/view.c:1986
#: src/view.c:1985
msgid "EdHex"
msgstr ""
#: src/view.c:1988
#: src/view.c:1987
msgid "UnWrap"
msgstr ""
#: gnome/gview.c:300 src/view.c:1988
#: gnome/gview.c:300 src/view.c:1987
msgid "Wrap"
msgstr ""
#: src/view.c:1991
#: src/view.c:1990
msgid "HxSrch"
msgstr ""
#: src/view.c:1994
#: src/view.c:1993
msgid "Raw"
msgstr ""
#: src/view.c:1994
#: src/view.c:1993
msgid "Parse"
msgstr ""
#: src/view.c:1998
#: src/view.c:1997
msgid "Unform"
msgstr ""
#: src/view.c:1998
#: src/view.c:1997
msgid "Format"
msgstr ""
@ -3661,19 +3661,19 @@ msgstr ""
msgid "Link"
msgstr ""
#: gnome/gdesktop.c:961 gnome/gscreen.c:365
#: gnome/gdesktop.c:963 gnome/gscreen.c:365
msgid "Properties"
msgstr ""
#: gnome/gdesktop.c:1080
#: gnome/gdesktop.c:1082
msgid "Open with..."
msgstr ""
#: gnome/gdesktop.c:1081 gnome/gscreen.c:321
#: gnome/gdesktop.c:1083 gnome/gscreen.c:321
msgid "Enter extra arguments:"
msgstr ""
#: gnome/gdesktop.c:1256
#: gnome/gdesktop.c:1258
msgid " Could not open %s directory"
msgstr ""

View File

@ -1,3 +1,14 @@
1998-04-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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
by sending the process to background, when executing temporary
files, we have to remove the files after the child process has
finished executing the code not after the calling do_execute.
* ext.c (exec_extension): Create temporary file exclusively.
Mon Apr 20 01:32:20 1998 Norbert Warmuth <k3190@fh-sw.de>
* configure.in: Don't try to link MC against SLang >= 1.0. I will

View File

@ -940,7 +940,7 @@ view_other_cmd (void)
if (output_starts_shell){
fprintf (stderr,
_("Type `exit' to return to the Midnight Commander\n\r\n\r"));
my_system (1, shell, NULL);
my_system (EXECUTE_AS_SHELL, shell, NULL);
} else
get_key_code (0);
}

View File

@ -45,6 +45,7 @@
#include "view.h"
#include "main.h"
#include "../vfs/vfs.h"
#include "x.h"
#include "cons.saver.h"
#include "layout.h"
@ -105,6 +106,7 @@ static void
exec_extension (char *filename, char *data, char **drops, int *move_dir, int start_line)
{
char *file_name;
int cmd_file_fd;
FILE *cmd_file;
int expand_prefix_found = 0;
int parameter_found = 0;
@ -117,9 +119,9 @@ exec_extension (char *filename, char *data, char **drops, int *move_dir, int sta
char buffer [1024];
char *p = 0;
char *localcopy = NULL;
int do_local_copy;
time_t localmtime = 0;
struct stat mystat;
int do_local_copy;
quote_func_t quote_func = name_quote;
/* Avoid making a local copy if we are doing a cd */
@ -133,11 +135,14 @@ exec_extension (char *filename, char *data, char **drops, int *move_dir, int sta
*/
file_name = strdup (tmpnam (NULL));
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");
fprintf (cmd_file, "#!%s\n", shell);
prompt [0] = 0;
for (;*data && *data != '\n'; data++){
if (parameter_found){
@ -270,8 +275,7 @@ exec_extension (char *filename, char *data, char **drops, int *move_dir, int sta
q[1] = 0;
do_cd (p, cd_parse_command);
} else {
shell_execute (file_name, 1);
shell_execute (file_name, EXECUTE_INTERNAL | EXECUTE_TEMPFILE);
if (console_flag)
{
handle_console (CONSOLE_SAVE);
@ -286,12 +290,14 @@ exec_extension (char *filename, char *data, char **drops, int *move_dir, int sta
#ifdef OLD_CODE
if (vfs_current_is_local ())
shell_execute (file_name, 1);
shell_execute (file_name, EXECUTE_INTERNAL);
else
message (1, _(" Warning "), _(" Can't execute commands on a Virtual File System directory "));
#endif
}
#ifndef PORT_DOES_BACKGROUND_EXEC
unlink (file_name);
#endif
if (localcopy) {
mc_stat (localcopy, &mystat);
mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime);