xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c (revision 11102:b91faef0c984)
13490Seschrock /*
23490Seschrock  * CDDL HEADER START
33490Seschrock  *
43490Seschrock  * The contents of this file are subject to the terms of the
53490Seschrock  * Common Development and Distribution License (the "License").
63490Seschrock  * You may not use this file except in compliance with the License.
73490Seschrock  *
83490Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93490Seschrock  * or http://www.opensolaris.org/os/licensing.
103490Seschrock  * See the License for the specific language governing permissions
113490Seschrock  * and limitations under the License.
123490Seschrock  *
133490Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
143490Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153490Seschrock  * If applicable, add the following below this CDDL HEADER, with the
163490Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
173490Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
183490Seschrock  *
193490Seschrock  * CDDL HEADER END
203490Seschrock  */
213490Seschrock /*
22*11102SGavin.Maltby@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
233490Seschrock  * Use is subject to license terms.
243490Seschrock  */
253490Seschrock 
263490Seschrock #include <libsysevent.h>
273490Seschrock #include <stdio.h>
283490Seschrock 
293490Seschrock int
main(int argc,char ** argv)303490Seschrock main(int argc, char **argv)
313490Seschrock {
323490Seschrock 	evchan_t *ch;
333490Seschrock 
343490Seschrock 	if (sysevent_evc_bind("channel_dtest", &ch,
353490Seschrock 	    EVCH_CREAT | EVCH_HOLD_PEND) != 0) {
363490Seschrock 		(void) fprintf(stderr, "failed to bind to sysevent channel\n");
373490Seschrock 		return (1);
383490Seschrock 	}
393490Seschrock 
403490Seschrock 	for (;;) {
413490Seschrock 		if (sysevent_evc_publish(ch, "class_dtest", "subclass_dtest",
423490Seschrock 		    "vendor_dtest", "publisher_dtest", NULL, EVCH_SLEEP) != 0) {
43*11102SGavin.Maltby@Sun.COM 			(void) sysevent_evc_unbind(ch);
443490Seschrock 			(void) fprintf(stderr, "failed to publisth sysevent\n");
453490Seschrock 			return (1);
463490Seschrock 		}
473490Seschrock 		sleep(1);
483490Seschrock 	}
493490Seschrock }
50