Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/cmd/aux/zerotrunc.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/*
 * cat standard input until you get a zero byte
 */

#include <u.h>
#include <libc.h>

void
main(void)
{
	char buf[4096];
	char *p;
	int n;

	while((n = read(0, buf, sizeof(buf))) > 0){
		p = memchr(buf, 0, n);
		if(p != nil)
			n = p-buf;
		if(n > 0)
			write(1, buf, n);
		if(p != nil)
			break;
	}
	exits(0);
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.