[bug #15352] Extensions not working
URL: http://savannah.gnu.org/bugs/?func=detailitemitem_id=15352 Summary: Extensions not working Project: GNU Midnight Commander Submitted by: sandolo Submitted on: Mon 01/02/06 at 13:08 Category: Core Severity: 3 - Normal Status: None Privacy: Public Assigned to: None Open/Closed: Open Release: 4.6.0 Platform Version: GNU/Linux ___ Details: Pressing ENTER on a filename should execute the action associated with the file extension, but it doesn't work for me; I only get an error BEEP. From 'strace' I discovered that... temp file for execution is created: 30748 open(/tmp/mc-daniel/mcextuVVMZb, O_RDWR|O_CREAT|O_TRUNC|O_EXCL|O_LARGEFILE, 0600) = 5 but the exec() get the filename truncated: 30753 execve(zsh, [zsh, -c, /bin/sh /tmp/mc-daniel/mcextuVVM...], [/* 62 vars */]) = -1 ENOENT (No such file or directory) As you can see, two letters are missing from the filename: /tmp/mc-daniel/mcextuVVMZb /tmp/mc-daniel/mcextuVVM I get the same behaviour on Slackware (clean build) and Gentoo (ebuild with patches), while on OpenBSD this work fine; also, this bug occurs with version 4.6.0 and 4.6.1. GNU Midnight Commander 4.6.0 Virtual File System: tarfs, extfs, cpiofs, ftpfs, fish, smbfs, undelfs With builtin Editor Using system-installed S-Lang library with terminfo database With subshell support as default With support for background operations With mouse support on xterm and Linux console With support for X11 events With internationalization support With multiple codepages support GNU Midnight Commander 4.6.1 Virtual File System: tarfs, extfs, cpiofs, ftpfs, fish, mcfs, smbfs, undelfs With builtin Editor Using system-installed S-Lang library with terminfo database With subshell support as default With support for background operations With mouse support on xterm and Linux console With support for X11 events With internationalization support ___ Reply to this item at: http://savannah.gnu.org/bugs/?func=detailitemitem_id=15352 ___ Message sent via/by Savannah http://savannah.gnu.org/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[bug #15352] Extensions not working
Follow-up Comment #1, bug #15352 (project mc): On Slackware, I've tried another package: ftp://ftp.slackware.com/pub/slackware/slackware-current/slackware/ap/mc-4.6.1-i486-1.tgz And it works fine. ___ Reply to this item at: http://savannah.gnu.org/bugs/?func=detailitemitem_id=15352 ___ Message sent via/by Savannah http://savannah.gnu.org/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[bug #15352] Extensions not working
Follow-up Comment #2, bug #15352 (project mc): It's a strace feature, it truncates strings. See man strace and its -s option. It has nothing to do with mc's behavior. On the other hand, the execve() call needs a full absolute path, a single zsh won't do it. I guess it's an execvp() library call that calls execve() as a last chance after failing to find zsh in the PATH. Use ltrace to trace the library calls if you're curious. I guess you simply don't have zsh installed. -- egmont ___ Reply to this item at: http://savannah.gnu.org/bugs/?func=detailitemitem_id=15352 ___ Message sent via/by Savannah http://savannah.gnu.org/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [RFE][PATCH] Display free space on device in panels
Hello Roland, thanks for your comments, attaching the patch better matching the mc coding style. Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ (o_ _o) //\ The worst evil in the world is refusal to think. //\ V_/_ _\_V --- mc-4.6.1a/src/screen.c.showfree 2006-01-02 12:22:51.0 +0100 +++ mc-4.6.1a/src/screen.c 2006-01-02 13:44:05.0 +0100 @@ -49,6 +49,7 @@ #define WANT_WIDGETS #include main.h /* the_menubar */ #include unixcompat.h +#include mountlist.h /* my_statfs */ #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) ) @@ -106,6 +107,12 @@ int filetype_mode = 1; /* The hook list for the select file function */ Hook *select_file_hook = 0; +/* Old current working directory for displaying free space */ +static char *old_cwd = NULL; + +/* Used to figure out how many free space we have */ +static struct my_statfs myfs_stats; + static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm); static int panel_event (Gpm_Event *event, void *); static void paint_frame (WPanel *panel); @@ -851,6 +858,41 @@ paint_dir (WPanel *panel) standend (); } + +static void +show_free_space(WPanel *panel) +{ +struct stat st; + +/* Don't try to stat non-local fs */ +if (!vfs_file_is_local(panel-cwd)) + return; + +if (old_cwd == NULL || strcmp(old_cwd, panel-cwd) == 0) { + init_my_statfs(); + g_free(old_cwd); + old_cwd = g_strdup(panel-cwd); +} + +my_statfs (myfs_stats, panel-cwd); +st = panel-dir.list [panel-selected].st; + +if (myfs_stats.avail 0 || myfs_stats.total 0) { + char buffer1 [6], buffer2[6], *tmp; + size_trunc_len (buffer1, 5, myfs_stats.avail, 1); + size_trunc_len (buffer2, 5, myfs_stats.total, 1); + tmp = g_strdup_printf (_(%s (%d%%) of %s), buffer1, myfs_stats.total 0 ? + (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0, + buffer2); + widget_move (panel-widget, panel-widget.lines-3, panel-widget.cols-2-strlen(tmp)); + if (panel-active) + attrset (REVERSE_COLOR); + addstr (tmp); + attrset (NORMAL_COLOR); + g_free (tmp); +} +} + static void mini_info_separator (WPanel *panel) { @@ -866,6 +908,7 @@ mini_info_separator (WPanel *panel) hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR, panel-widget.cols - 2); #endif/* !HAVE_SLANG */ +show_free_space (panel); } static void @@ -929,6 +972,8 @@ show_dir (WPanel *panel) widget_move (panel-widget, 0, panel-widget.cols - 3); addstr (v); +mini_info_separator (panel); + if (panel-active) standend (); } ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[bug #15352] Extensions not working
Follow-up Comment #3, bug #15352 (project mc): zsh is installed and is in $PATH. I tried with bash, with same result: 16974 execve(bash, [bash, -c, /bin/sh /tmp/mc-daniel/mcextnt0YXc], [/* 61 vars */]) = -1 ENOENT (No such file or directory) As you wrote, there's no string truncation, but the problem still persist :( ___ Reply to this item at: http://savannah.gnu.org/bugs/?func=detailitemitem_id=15352 ___ Messaggio inviato con/da Savannah http://savannah.gnu.org/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[bug #15352] Extensions not working
Follow-up Comment #4, bug #15352 (project mc): As noticed by egmont, the exec() fails because the system cannot find the shell without the full path. It is my fault, since my ~/.screenrc contains: shell zsh So, $SHELL contains only zsh. Sorry for bothering :) ___ Reply to this item at: http://savannah.gnu.org/bugs/?func=detailitemitem_id=15352 ___ Messaggio inviato con/da Savannah http://savannah.gnu.org/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
subshell output swallowed (patch)
Hi, When an external command is executed in mc with subshell support, quite often some characters of its output are swallowed. Maybe it's most noticable with the ls command in a directory where there are a lot of files and ls outputs them in more columns. Just launch a terminal emulator, start mc, press ^O so that the panels disappear, and run ls a several times. Sure you'll see some occasions when the columns are not lined up correctly. For example, in a 70-column wide terminal, standing in the source tree of Python-2.4.2 in the Lib directory, an ls now produced this output to me: [...] fileinput.pyplat-irix6toaiff.py fnmatch.py plat-linux2 tokenize.py formatter.pyplat-mac token.py fpformat.pyplat-netbsd1 traceback.py ftplib.py plat-next3trace.py __future__.py plat-os2emx tzparse.py getopt.py plat-riscos types.py [...] The bug is reproducible in different terminal emulators, and does not occur if ls is executed outside mc, or inside mc -u. An strace -e trace=read,write of a similar case showed this: [...] read(4, \33[0mcopy.py\33[0m\33[0mi..., 100) = 100 write(1, \33[0mcopy.py\33[0m\33[0mi..., 100) = 100 read(4, m \33[0m_strptime.py\33[0m ..., 100) = 62 write(1, m \33[0m_strptime.py\33[0m ..., 62) = 62 read(4, \33[0mcopy_reg.py\33[0m\33[0mi..., 100) = 100 write(1, \33[0mcopy_reg.py\33[0m\33[0mi..., 100) = 53 --- SIGCHLD (Child exited) @ 0 (0) --- read(4, py\33[0m\33[0msubprocess.py\33..., 100) = 100 write(1, py\33[0m\33[0msubprocess.py\33..., 100) = 100 read(4, mghdr.py\33[0m \33[0mpipes..., 100) = 100 write(1, mghdr.py\33[0m \33[0mpipes..., 100) = 100 [...] So, when ls exits, mc receives a sigchild, which interrupts the write call that transfers the output of ls from the subshell to its real output, but the interrupted call is not finished, in this particular case 47 bytes are skipped. See the attached patch which fixes this problem. bye, Egmont diff -Naur mc-4.6.1.orig/ChangeLog mc-4.6.1/ChangeLog --- mc-4.6.1.orig/ChangeLog 2005-07-23 18:51:11.0 +0200 +++ mc-4.6.1/ChangeLog 2006-01-02 19:00:41.0 +0100 @@ -1,3 +1,8 @@ +2006-01-02 Egmont Koblinger [EMAIL PROTECTED] + + * src/subshell.c: restart write() calls interrupted by sigchld + which lead to some bytes being swallowed from the subshell's output. + 2005-07-23 Roland Illig [EMAIL PROTECTED] * configure.ac: getgrouplist() is not used anymore, so there' no diff -Naur mc-4.6.1.orig/src/subshell.c mc-4.6.1/src/subshell.c --- mc-4.6.1.orig/src/subshell.c2005-06-07 11:19:19.0 +0200 +++ mc-4.6.1/src/subshell.c 2006-01-02 18:58:01.0 +0100 @@ -150,6 +150,30 @@ /* + * Write all data, even if the write() call is interrupted. + */ +static ssize_t +write_all (int fd, const void *buf, size_t count) +{ +ssize_t ret; +ssize_t written = 0; +while (count 0) { + ret = write (fd, buf, count); + if (ret 0) { + if (errno == EINTR) { + continue; + } else { + return written 0 ? written : ret; + } + } + buf += ret; + count -= ret; + written += ret; +} +return written; +} + +/* * Prepare child process to running the shell and run it. * * Modifies the global variables (in the child process only): @@ -476,7 +500,7 @@ tcsh_fifo); break; } -write (subshell_pty, precmd, strlen (precmd)); +write_all (subshell_pty, precmd, strlen (precmd)); /* Wait until the subshell has started up and processed the command */ @@ -533,16 +557,16 @@ subshell_state = ACTIVE; /* FIXME: possibly take out this hack; the user can re-play it by hitting C-hyphen a few times! */ - write (subshell_pty, \b, 2); /* Hack to make prompt reappear */ + write_all (subshell_pty, \b, 2); /* Hack to make prompt reappear */ } } else /* MC has passed us a user command */ { if (how == QUIETLY) - write (subshell_pty, , 1); + write_all (subshell_pty, , 1); /* FIXME: if command is long (8KB ?) we go comma */ - write (subshell_pty, command, strlen (command)); - write (subshell_pty, \n, 1); + write_all (subshell_pty, command, strlen (command)); + write_all (subshell_pty, \n, 1); subshell_state = RUNNING_COMMAND; subshell_ready = FALSE; } @@ -767,21 +791,21 @@ /* The initial space keeps this out of the command history (in bash because we set HISTCONTROL=ignorespace) */ -write (subshell_pty, cd , 4); +write_all (subshell_pty, cd , 4); if (*directory) { char *temp = subshell_name_quote (directory); if (temp) { -