Lines 1-56
Link Here
|
1 |
--- OpenFilesScreen.c.orig 2010-01-26 03:53:04.000000000 +0800 |
|
|
2 |
+++ OpenFilesScreen.c 2010-01-26 03:56:23.000000000 +0800 |
3 |
@@ -26,7 +26,7 @@ |
4 |
typedef struct OpenFiles_ProcessData_ { |
5 |
char* data[256]; |
6 |
struct OpenFiles_FileData_* files; |
7 |
- bool failed; |
8 |
+ int error; |
9 |
} OpenFiles_ProcessData; |
10 |
|
11 |
typedef struct OpenFiles_FileData_ { |
12 |
@@ -80,16 +80,18 @@ |
13 |
OpenFiles_ProcessData* process = calloc(sizeof(OpenFiles_ProcessData), 1); |
14 |
OpenFiles_FileData* file = NULL; |
15 |
OpenFiles_ProcessData* item = process; |
16 |
- process->failed = true; |
17 |
bool anyRead = false; |
18 |
+ |
19 |
+ if (!fd) { |
20 |
+ process->error = 127; |
21 |
+ return process; |
22 |
+ } |
23 |
+ |
24 |
while (!feof(fd)) { |
25 |
int cmd = fgetc(fd); |
26 |
- if (cmd == EOF && !anyRead) { |
27 |
- process->failed = true; |
28 |
+ if (cmd == EOF && !anyRead) |
29 |
break; |
30 |
- } |
31 |
anyRead = true; |
32 |
- process->failed = false; |
33 |
char* entry = malloc(1024); |
34 |
if (!fgets(entry, 1024, fd)) break; |
35 |
char* newline = strrchr(entry, '\n'); |
36 |
@@ -106,7 +108,7 @@ |
37 |
} |
38 |
item->data[cmd] = entry; |
39 |
} |
40 |
- pclose(fd); |
41 |
+ process->error = pclose(fd); |
42 |
return process; |
43 |
} |
44 |
|
45 |
@@ -115,8 +117,10 @@ |
46 |
int index = MAX(Panel_getSelectedIndex(panel), 0); |
47 |
Panel_prune(panel); |
48 |
OpenFiles_ProcessData* process = OpenFilesScreen_getProcessData(this->process->pid); |
49 |
- if (process->failed) { |
50 |
+ if (process->error == 127) { |
51 |
Panel_add(panel, (Object*) ListItem_new("Could not execute 'lsof'. Please make sure it is available in your $PATH.", 0)); |
52 |
+ } else if (process->error == 1) { |
53 |
+ Panel_add(panel, (Object*) ListItem_new("Failed listing open files.", 0)); |
54 |
} else { |
55 |
OpenFiles_FileData* file = process->files; |
56 |
while (file) { |