1
1

* background.c (tell_parent): Eliminate.

(background_attention): Use error code instead.
* file.c (panel_operate): Exit with code 0, not 1.
Этот коммит содержится в:
Pavel Roskin 2003-10-26 05:42:29 +00:00
родитель 211ce16fac
Коммит 26e444a11c
4 изменённых файлов: 22 добавлений и 35 удалений

Просмотреть файл

@ -1,5 +1,9 @@
2003-10-26 Pavel Roskin <proski@gnu.org>
* background.c (tell_parent): Eliminate.
(background_attention): Use error code instead.
* file.c (panel_operate): Exit with code 0, not 1.
* wtools.c: Merge mc_message() and message() into one background
safe function message(). Fix all callers.

Просмотреть файл

@ -43,6 +43,11 @@
#include "fileopctx.h" /* FileOpContext */
#include "key.h" /* add_select_channel(), delete_select_channel() */
enum ReturnType {
Return_String,
Return_Integer
};
/* If true, this is a background process */
int we_are_background = 0;
@ -195,24 +200,23 @@ background_attention (int fd, void *closure)
ctx = closure;
bytes = read (fd, &routine, sizeof (routine));
if (bytes < (sizeof (routine))){
if (bytes < (sizeof (routine))) {
char *background_process_error = _(" Background process error ");
unregister_task_running (ctx->pid, fd);
waitpid (ctx->pid, &status, 0);
if (errno == ECHILD)
message (1, background_process_error, _(" Child died unexpectedly "));
else
if (!waitpid (ctx->pid, &status, WNOHANG)) {
/* the process is still running, but it misbehaves - kill it */
kill (ctx->pid, SIGTERM);
message (1, background_process_error, _(" Unknown error in child "));
return 0;
}
return 0;
}
/* 0 means happy end */
if (WIFEXITED (status) && (WEXITSTATUS (status) == 0))
return 0;
message (1, background_process_error, _(" Child died unexpectedly "));
/* If the routine is zero, then the child is telling us that he is dying */
if ((long) routine == MSG_CHILD_EXITING){
unregister_task_running (ctx->pid, fd);
waitpid (ctx->pid, &status, 0);
return 0;
}
@ -403,10 +407,4 @@ parent_call_string (void *routine, int argc, ...)
return str;
}
void
tell_parent (int msg)
{
write (parent_fd, &msg, sizeof (int));
}
#endif /* WITH_BACKGROUND */

Просмотреть файл

@ -2,18 +2,6 @@
#define __BACKGROUND_H
#ifdef WITH_BACKGROUND
/*
* Used for parent/child communication. These are numbers that
* could not possible be a routine address.
*/
enum {
MSG_CHILD_EXITING
};
enum ReturnType {
Return_String,
Return_Integer
};
enum TaskState {
Task_Running,
@ -30,14 +18,12 @@ typedef struct TaskList {
extern struct TaskList *task_list;
void tell_parent (int msg);
struct FileOpContext;
int do_background (struct FileOpContext *ctx, char *info);
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);
void unregister_task_running (pid_t pid, int fd);
extern int we_are_background;
#endif /* !WITH_BACKGROUND */

Просмотреть файл

@ -2124,8 +2124,7 @@ panel_operate (void *source_panel, FileOperation operation,
/* Let our parent know we are saying bye bye */
if (we_are_background) {
vfs_shut ();
tell_parent (MSG_CHILD_EXITING);
_exit (1);
_exit (0);
}
#endif /* WITH_BACKGROUND */