Ejemplo n.º 1
0
int
main(int argc, char *argv[])
{
	int fd;

	printf("This is the first message\n");
	if (isatty(STDOUT_FILENO)) {
		char *ttynm;

		CHECKn(ttynm = ttyname(STDOUT_FILENO));
		printf("tty is %s\n", ttynm);
		CHECKe(fd = open(ttynm, O_RDWR));
	} else {
		printf("IGNORED: stdout is not a tty: this test needs a tty\n");
		SUCCEED;
	}

	CHECKn(printf("This output is necessary to set the stdout fd to NONBLOCKING\n"));

	/* do a dup2 */
	CHECKe(dup2(fd, STDOUT_FILENO));
	CHECKe(write(STDOUT_FILENO, should_succeed,
	    (size_t)strlen(should_succeed)));
	CHECKe(execve(new_argv[0], new_argv, environ));
	DIE(errno, "execve %s", new_argv[0]);
}
Ejemplo n.º 2
0
int
main(int argc, char **argv)
{
	pthread_t prod_th, cons_th;
	long counter = 4;

	CHECKn(sem_destroy(&cons_sem));
	ASSERT(errno == EINVAL);

	val = 0;

	CHECKr(sem_init(&cons_sem, 0, 0));
	CHECKr(sem_init(&prod_sem, 0, 1));

	CHECKr(pthread_create(&prod_th, NULL, producer, &counter));
	CHECKr(pthread_create(&cons_th, NULL, consumer, &counter));

	CHECKr(pthread_join(prod_th, NULL));
	CHECKr(pthread_join(cons_th, NULL));

	pthread_exit(NULL);

	CHECKr(sem_destroy(&prod_sem));
	CHECKr(sem_destroy(&cons_sem));

	SUCCEED;
}
Ejemplo n.º 3
0
/*
NAME    {* fdd\_printset *}
EXTRA   {* fdd\_fprintset *}
SECTION {* fdd *}
SHORT   {* prints a BDD for a finite domain block *}
PROTO   {* void fdd_printset(BDD r)
void fdd_fprintset(FILE *ofile, BDD f) *}
DESCR   {* Prints the BDD {\tt f} using a set notation as in
           {\tt bdd\_printset} but with the index of the finite domain blocks
	   included instead of the BDD variables. It is possible to specify
	   a printing callback function with {\tt fdd\_file\_hook} or
	   {\tt fdd\_strm\_hook} which can be used to print the FDD
	   identifier in a readable form. *}
ALSO    {* bdd\_printset, fdd\_file\_hook, fdd\_strm\_hook *}
*/
void fdd_printset(BDD r)
{
   CHECKn(r);
   fdd_fprintset(stdout, r);
}