* background.c: Clean up includes.

(do_background): Set current_dlg to NULL for the child process.
* dialog.h (do_complete_refresh): Don't use we_are_background.
* file.h: Remove dependency on background.h.
* background.h: Define we_are_background.  Move mc_message() ...
* wtools.h: ... here.
* key.h: Don't define we_are_background.
* slint.c (mc_refresh): Use current_dialog instead of
we_are_background to fix compilation without WITH_BACKGROUND.
This commit is contained in:
Pavel Roskin 2003-10-26 00:58:14 +00:00
parent 6cc1e873ef
commit a08f91eb63
9 changed files with 37 additions and 21 deletions

View File

@ -1,5 +1,15 @@
2003-10-25 Pavel Roskin <proski@gnu.org>
* background.c: Clean up includes.
(do_background): Set current_dlg to NULL for the child process.
* dialog.h (do_complete_refresh): Don't use we_are_background.
* file.h: Remove dependency on background.h.
* background.h: Define we_are_background. Move mc_message() ...
* wtools.h: ... here.
* key.h: Don't define we_are_background.
* slint.c (mc_refresh): Use current_dialog instead of
we_are_background to fix compilation without WITH_BACKGROUND.
* background.c (do_background): Use pipe() instead of less
portable socketpair(). Close comm[0] in the child.

View File

@ -36,16 +36,12 @@
#include <stdio.h>
#include "global.h"
#include "tty.h"
#include "dialog.h"
#include "widget.h"
#include "background.h"
#include "tty.h" /* doupdate() */
#include "dialog.h" /* do_refresh() */
#include "wtools.h"
#include "fileopctx.h"
#include "key.h" /* For add_select_channel(), delete_select_channel() */
#include "eregex.h"
#include "file.h"
#include "filegui.h"
#include "fileopctx.h" /* FileOpContext */
#include "key.h" /* add_select_channel(), delete_select_channel() */
/* If true, this is a background process */
int we_are_background = 0;
@ -123,6 +119,7 @@ do_background (struct FileOpContext *ctx, char *info)
close (comm[0]);
parent_fd = comm[1];
we_are_background = 1;
current_dlg = NULL;
/* Make stdin/stdout/stderr point somewhere */
close (0);

View File

@ -1,7 +1,9 @@
#ifndef __BACKGROUND_H
#define __BACKGROUND_H
/* Used for parent/child communication. These are numbers that
#ifdef WITH_BACKGROUND
/*
* Used for parent/child communication. These are numbers that
* could not possible be a routine address.
*/
enum {
@ -19,10 +21,10 @@ enum TaskState {
};
typedef struct TaskList {
int fd;
int fd;
pid_t pid;
int state;
char *info;
int state;
char *info;
struct TaskList *next;
} TaskList;
@ -36,9 +38,8 @@ int parent_call (void *routine, struct FileOpContext *ctx, int argc, ...);
char *parent_call_string (void *routine, int argc, ...);
void unregister_task_running (pid_t, int fd);
extern int we_are_background;
/* Show message box, background safe */
void mc_message (int flags, char *title, const char *text, ...)
__attribute__ ((format (printf, 3, 4)));
#endif /* !WITH_BACKGROUND */
#endif
#endif /* __BACKGROUND_H */

View File

@ -280,7 +280,7 @@ do_complete_refresh (Dlg_head *dlg)
void
do_refresh (void)
{
if (we_are_background || !current_dlg)
if (!current_dlg)
return;
if (fast_refresh)

View File

@ -81,6 +81,7 @@
#include "layout.h"
#include "widget.h"
#include "wtools.h"
#include "background.h" /* tell_parent() */
/* Needed for current_panel, other_panel and WTree */
#include "dir.h"

View File

@ -2,7 +2,6 @@
#define __FILE_H
#include "fileopctx.h"
#include "background.h"
extern int safe_delete;

View File

@ -75,7 +75,6 @@ typedef const struct {
} key_code_name_t;
extern key_code_name_t key_name_conv_tab [];
extern int we_are_background;
/* Set keypad mode (xterm and linux console only) */
void numeric_keypad_mode (void);

View File

@ -35,6 +35,7 @@
#include "main.h" /* extern: force_colors */
#include "win.h" /* do_exit_ca_mode */
#include "setup.h"
#include "dialog.h" /* current_dlg */
#ifdef HAVE_SLANG
@ -523,6 +524,6 @@ int got_interrupt (void)
void
mc_refresh (void)
{
if (!we_are_background)
if (current_dlg)
refresh ();
}

View File

@ -66,12 +66,20 @@ char *input_expand_dialog (char *header, char *text, char *def_text);
void query_set_sel (int new_sel);
/* Create message box but don't dismiss it yet, not background safe */
struct Dlg_head *create_message (int flags, const char *title,
const char *text, ...)
__attribute__ ((format (printf, 3, 4)));
/* Show message box, not background safe */
void message (int flags, const char *title, const char *text, ...)
__attribute__ ((format (printf, 3, 4)));
/* Show message box, background safe */
void mc_message (int flags, char *title, const char *text, ...)
__attribute__ ((format (printf, 3, 4)));
/* Use this as header for message() - it expands to "Error" */
#define MSG_ERROR ((char *) -1)