Re: cron job causes fwrite: broken pipe error, runs fine on command line
On Mon, Nov 9, 2009 at 12:03 PM, John Mendenhall wrote: >> On Mon, Nov 9, 2009 at 2:19 PM, John Mendenhall wrote: >> > I have several openbsd 4.4 boxes, all of which are running >> > spamd. I have a cron job which runs a script, which has the >> > following commands in it: >> >> Well, sort is obviously calling fwrite to write on stdout, which >> head reads. When head has had enough, it closes its input, >> which is from the pipe. fwrite then terminates with an EPIPE >> error, which sort is not (seemingly) handling properly. (Looks >> like it is calling warn(3) or err(3).) Maybe sort(3) is not complaining >> if isatty(fileno(stdout)). Only the source knows for sure. Not quite. cron is invoking programs with SIGPIPE ignored, thus the reported behavior from sort. I don't see this (the ignoring) on the other systems I have access to and don't see anything in the standard that would call for that, so I think this is a bug in our cron. I encourage the OP to use sendbug to submit a report for this so we don't lose track of it. >> The mystery to me is why the error message does not appear >> when the pipe is run on a tty. (I can duplicate your error easily). Because it gets SIGPIPE and exits quietly. Philip Guenther
Re: cron job causes fwrite: broken pipe error, runs fine on command line
On Mon, Nov 9, 2009 at 3:03 PM, John Mendenhall wrote: >> The mystery to me is why the error message does not appear >> when the pipe is run on a tty. (I can duplicate your error easily). >> >> To me this looks like normal operation. You seem to be getting >> the output you want, right? > > Yup. So, I guess I can just throw away the standard error, to > clean it up a bit. Definitely not a real issue. Just a curiosity > that I like solving. I was just wondering why it runs differently > in different environments. Well, output in sort(3) is through a macro, sort.h: if (!fwrite(ptr, size, n, f)) \ sort.h: err(2, "fwrite"); \ There's no funny business with isatty(). It might have to do with buffering, different buffer size in each case? That's a shot in the dark. Timing? I really don't know. (But I am, like you, curious.) I can't imagine the source for err(3) making a decision, so this must be buried in stdio source for fwrite. Maybe even in the shell that set up the pipe in the first place. Maybe in a system call... Maybe in the lunar phase... Anyway 2>/dev/null can work wonders for this sort of thing. Dave
Re: cron job causes fwrite: broken pipe error, runs fine on command line
Dave, > On Mon, Nov 9, 2009 at 2:19 PM, John Mendenhall wrote: > > I have several openbsd 4.4 boxes, all of which are running > > spamd. I have a cron job which runs a script, which has the > > following commands in it: > > Well, sort is obviously calling fwrite to write on stdout, which > head reads. When head has had enough, it closes its input, > which is from the pipe. fwrite then terminates with an EPIPE > error, which sort is not (seemingly) handling properly. (Looks > like it is calling warn(3) or err(3).) Maybe sort(3) is not complaining > if isatty(fileno(stdout)). Only the source knows for sure. > > The mystery to me is why the error message does not appear > when the pipe is run on a tty. (I can duplicate your error easily). > > To me this looks like normal operation. You seem to be getting > the output you want, right? Yup. So, I guess I can just throw away the standard error, to clean it up a bit. Definitely not a real issue. Just a curiosity that I like solving. I was just wondering why it runs differently in different environments. JohnM -- john mendenhall j...@surfutopia.net surf utopia internet services
Re: cron job causes fwrite: broken pipe error, runs fine on command line
On Mon, Nov 9, 2009 at 2:37 PM, Peter N. M. Hansteen wrote: > John Mendenhall writes: > >> oldest spamdb grey entry date timestamp: >> sort: fwrite: Broken pipe > > Just to eliminate the obvious - how much disk space is available for > temporary files? Could you be on the low side? You won't get EPIPE for no disk space. You'll get "no space left on device". (ENOSPC). But Unix doesn't write pipes to disk. That's an MS-DOS trick ;-) Unix does pipes in the kernel. Dave
Re: cron job causes fwrite: broken pipe error, runs fine on command line
On Mon, Nov 9, 2009 at 2:19 PM, John Mendenhall wrote: > I have several openbsd 4.4 boxes, all of which are running > spamd. I have a cron job which runs a script, which has the > following commands in it: > Well, sort is obviously calling fwrite to write on stdout, which head reads. When head has had enough, it closes its input, which is from the pipe. fwrite then terminates with an EPIPE error, which sort is not (seemingly) handling properly. (Looks like it is calling warn(3) or err(3).) Maybe sort(3) is not complaining if isatty(fileno(stdout)). Only the source knows for sure. The mystery to me is why the error message does not appear when the pipe is run on a tty. (I can duplicate your error easily). To me this looks like normal operation. You seem to be getting the output you want, right? dave -- Caution, this account is hosted by gmail. Strangers scan the content of all mail transiting such accounts.
Re: cron job causes fwrite: broken pipe error, runs fine on command line
Peter, > John Mendenhall writes: > > oldest spamdb grey entry date timestamp: > > sort: fwrite: Broken pipe > > > Just to eliminate the obvious - how much disk space is available for > temporary files? Could you be on the low side? > - Peter Seems I have plenty. This is happening on all of our machines. Here is one of them: Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/sd0a 2068384 56738 1908228 3%/ /dev/sd0f33028404 2288308 29088676 7%/home /dev/sd0e33027494687292 30688828 2%/mail /dev/sd0h 2052352 6 1949730 0%/tmp /dev/sd0g16514194700424 14988062 4%/usr /dev/sd0d 151562932 4289600 139695186 3%/var JohnM -- john mendenhall j...@surfutopia.net surf utopia internet services
Re: cron job causes fwrite: broken pipe error, runs fine on command line
John Mendenhall writes: > oldest spamdb grey entry date timestamp: > > sort: fwrite: Broken pipe > Just to eliminate the obvious - how much disk space is available for temporary files? Could you be on the low side? - Peter -- Peter N. M. Hansteen, member of the first RFC 1149 implementation team http://bsdly.blogspot.com/ http://www.bsdly.net/ http://www.nuug.no/ "Remember to set the evil bit on all malicious network traffic" delilah spamd[29949]: 85.152.224.147: disconnected after 42673 seconds.
cron job causes fwrite: broken pipe error, runs fine on command line
I have several openbsd 4.4 boxes, all of which are running spamd. I have a cron job which runs a script, which has the following commands in it: - #!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH FIELDNUM=6 echo oldest spamdb grey entries: spamdb | grep ^GREY | sort -t \| -k $FIELDNUM -n | head echo echo oldest spamdb grey entry date timestamp: DATEINSECONDS=`spamdb | grep ^GREY | sort -t \| -k $FIELDNUM -n | head -1 | cut -d\| -f$FIELDNUM` date -r $DATEINSECONDS - The purpose of the script is to show me the oldest entries in the spamdb. This is the output (with destination domains replaced with 'domain'): - oldest spamdb grey entries: GREY|189.62.148.55|bd3e9437.virtua.com.br|||1257739194|1257753594|1257753594|1|0 GREY|209.50.235.237|yourhomejob.biz|||1257739196|1257753596|1257753596|2|0 GREY|117.4.19.147|localhost|||1257739199|1257753599|1257753599|1|0 GREY|187.42.168.180|18777208209.telemar.net.br|||1257739199|1257753599|1257753599|1|0 GREY|117.0.122.41|localhost|||1257739200|1257753600|1257753600|1|0 GREY|187.42.168.180|18777208209.telemar.net.br|||1257739200|1257753600|1257753600| +1|0 GREY|187.42.168.180|18777208209.telemar.net.br|||1257739200|1257753600|1257753600 +|1|0 GREY|187.42.168.180|18777208209.telemar.net.br|||1257739201|1257753601|1257753601 +|1|0 GREY|187.42.168.180|18777208209.telemar.net.br|||1257739202|1257753602|125775360 +2|1|0 GREY|124.121.20.135|TVCMVZJBGA|||1257739205|1257753605|1257753605|1|0 sort: fwrite: Broken pipe oldest spamdb grey entry date timestamp: sort: fwrite: Broken pipe Sun Nov 8 19:59:54 PST 2009 - uname -a produces 'OpenBSD yosemite.surfutopia.net 4.4 GENERIC.MP#844 i386' I have read the associated man pages. I have searched the search engines. I was not able to find anything to try to fix this. I am sure this has something to do with terminals or ttys, or something like that. Or it could just be I am dumping the additional data spit out by sort and sort can't handle that, from within cron. I am hoping this is just something stupid I am doing wrong that is easy to fix. Please point me in the direction to find the solution for this issue. Thanks in advance! JohnM -- john mendenhall j...@surfutopia.net surf utopia internet services