* background.c (tell_parent): Eliminate.
(background_attention): Use error code instead. * file.c (panel_operate): Exit with code 0, not 1.
Этот коммит содержится в:
родитель
211ce16fac
Коммит
26e444a11c
@ -1,5 +1,9 @@
|
|||||||
2003-10-26 Pavel Roskin <proski@gnu.org>
|
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
|
* wtools.c: Merge mc_message() and message() into one background
|
||||||
safe function message(). Fix all callers.
|
safe function message(). Fix all callers.
|
||||||
|
|
||||||
|
@ -43,6 +43,11 @@
|
|||||||
#include "fileopctx.h" /* FileOpContext */
|
#include "fileopctx.h" /* FileOpContext */
|
||||||
#include "key.h" /* add_select_channel(), delete_select_channel() */
|
#include "key.h" /* add_select_channel(), delete_select_channel() */
|
||||||
|
|
||||||
|
enum ReturnType {
|
||||||
|
Return_String,
|
||||||
|
Return_Integer
|
||||||
|
};
|
||||||
|
|
||||||
/* If true, this is a background process */
|
/* If true, this is a background process */
|
||||||
int we_are_background = 0;
|
int we_are_background = 0;
|
||||||
|
|
||||||
@ -195,24 +200,23 @@ background_attention (int fd, void *closure)
|
|||||||
ctx = closure;
|
ctx = closure;
|
||||||
|
|
||||||
bytes = read (fd, &routine, sizeof (routine));
|
bytes = read (fd, &routine, sizeof (routine));
|
||||||
if (bytes < (sizeof (routine))){
|
if (bytes < (sizeof (routine))) {
|
||||||
char *background_process_error = _(" Background process error ");
|
char *background_process_error = _(" Background process error ");
|
||||||
|
|
||||||
unregister_task_running (ctx->pid, fd);
|
unregister_task_running (ctx->pid, fd);
|
||||||
waitpid (ctx->pid, &status, 0);
|
if (!waitpid (ctx->pid, &status, WNOHANG)) {
|
||||||
|
/* the process is still running, but it misbehaves - kill it */
|
||||||
if (errno == ECHILD)
|
kill (ctx->pid, SIGTERM);
|
||||||
message (1, background_process_error, _(" Child died unexpectedly "));
|
|
||||||
else
|
|
||||||
message (1, background_process_error, _(" Unknown error in child "));
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,10 +407,4 @@ parent_call_string (void *routine, int argc, ...)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
tell_parent (int msg)
|
|
||||||
{
|
|
||||||
write (parent_fd, &msg, sizeof (int));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* WITH_BACKGROUND */
|
#endif /* WITH_BACKGROUND */
|
||||||
|
@ -2,18 +2,6 @@
|
|||||||
#define __BACKGROUND_H
|
#define __BACKGROUND_H
|
||||||
|
|
||||||
#ifdef WITH_BACKGROUND
|
#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 {
|
enum TaskState {
|
||||||
Task_Running,
|
Task_Running,
|
||||||
@ -30,14 +18,12 @@ typedef struct TaskList {
|
|||||||
|
|
||||||
extern struct TaskList *task_list;
|
extern struct TaskList *task_list;
|
||||||
|
|
||||||
void tell_parent (int msg);
|
|
||||||
|
|
||||||
struct FileOpContext;
|
struct FileOpContext;
|
||||||
int do_background (struct FileOpContext *ctx, char *info);
|
int do_background (struct FileOpContext *ctx, char *info);
|
||||||
int parent_call (void *routine, struct FileOpContext *ctx, int argc, ...);
|
int parent_call (void *routine, struct FileOpContext *ctx, int argc, ...);
|
||||||
char *parent_call_string (void *routine, 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;
|
extern int we_are_background;
|
||||||
|
|
||||||
#endif /* !WITH_BACKGROUND */
|
#endif /* !WITH_BACKGROUND */
|
||||||
|
@ -2124,8 +2124,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
|||||||
/* Let our parent know we are saying bye bye */
|
/* Let our parent know we are saying bye bye */
|
||||||
if (we_are_background) {
|
if (we_are_background) {
|
||||||
vfs_shut ();
|
vfs_shut ();
|
||||||
tell_parent (MSG_CHILD_EXITING);
|
_exit (0);
|
||||||
_exit (1);
|
|
||||||
}
|
}
|
||||||
#endif /* WITH_BACKGROUND */
|
#endif /* WITH_BACKGROUND */
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user