Skip to content
Browse files

Implement jscan -o. Take the patch from Steve and add some additional

checks to the write() to deal with EINTR and EAGAIN.

Submitted-by: "Steve O'Hara-Smith" <steve@sohara.org>
  • Loading branch information...
1 parent ecda632 commit e589f0ed8046c720d1987a9424a289bff7b025bc Matthew Dillon committed Jun 26, 2007
Showing with 23 additions and 1 deletion.
  1. +23 −1 sbin/jscan/dump_output.c
View
24 sbin/jscan/dump_output.c
@@ -31,13 +31,35 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $DragonFly: src/sbin/jscan/dump_output.c,v 1.3 2005/09/07 19:10:09 dillon Exp $
+ * $DragonFly: src/sbin/jscan/dump_output.c,v 1.4 2007/06/26 20:47:58 dillon Exp $
*/
#include "jscan.h"
void
dump_output(struct jsession *ss, struct jdata *jd)
{
+ int n;
+ int r;
+
+ for (n = 0; n < jd->jd_size; n += r) {
+ r = write(1, jd->jd_data + n, jd->jd_size - n);
+ if (r == 0)
+ break;
+ if (r < 0) {
+ r = 0;
+ if (errno == EINTR)
+ continue;
+ if (errno == EAGAIN) {
+ usleep(1000000 / 5);
+ continue;
+ }
+ break;
+ }
+ }
+ if (n != jd->jd_size) {
+ perror("write(stdout)");
+ exit(1);
+ }
jsession_update_transid(ss, jd->jd_transid);
}

0 comments on commit e589f0e

Please sign in to comment.
Something went wrong with that request. Please try again.