ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FreeBSDAdmin/Mail/SpamUpdate.c
(Generate patch)

Comparing FreeBSDAdmin/Mail/SpamUpdate.c (file contents):
Revision 819 by douglas, 2006-07-03T22:15:40-07:00 vs.
Revision 822 by douglas, 2006-07-04T16:57:34-07:00

# Line 105 | Line 105 | static void learn()
105                          check(close(file), environment);
106                  }
107  
108 <                int pipe_[2];
108 >                int between[2];
109  
110 <                check(pipe(pipe_), environment);
110 >                check(pipe(between), environment);
111  
112                  pid_t assassin;
113  
114                  if (!(assassin = check(fork(), environment)))
115                  {
116 <                        check(dup2(pipe_[1], 1), environment);
117 <                        check(close(pipe_[0]), environment);
116 >                        check(dup2(between[1], 1), environment);
117 >                        check(close(between[0]), environment);
118  
119                          const char *args[count ? count + 3 : 5];
120                          
# Line 135 | Line 135 | static void learn()
135                          check(execv(ASSASSIN, (char *const *)args), environment);
136                  }
137  
138 <                check(close(pipe_[1]), environment);
138 >                check(close(between[1]), environment);
139 >
140 >                int in[2];
141 >
142 >                check(pipe(in), environment);
143  
144                  pid_t sed;
145  
146                  if (!(sed = check(fork(), environment)))
147                  {
148 <                        check(dup2(pipe_[0], 0), environment);
148 >                        check(dup2(between[0], 0), environment);
149 >                        check(dup2(in[1], 1), environment);
150 >                        check(close(in[0]), environment);
151                          check(execl(SED, "sed", "-e", INDENT, "-e", PERIOD, NULL), environment);
152                  }
153  
154 <                check(close(pipe_[0]), environment);
154 >                check(close(between[0]), environment);
155 >                check(close(in[1]), environment);
156 >
157 >                FILE *sed_ = fdopen(in[0], "r");
158 >                size_t size;
159 >
160 >                do
161 >                {
162 >                        char *line = fcheck(fgetln(sed_, &size), sed_, environment);
163 >
164 >                        fwrite(line, size, sizeof (char), stdout);
165 >                }
166 >                while (size != 0);
167 >
168 >                if (fclose(sed_))
169 >                        longjmp(environment, 1);
170  
171                  int status;
172  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines