10f66f451Sopenharmony_ci/* hello.c - A hello world program. (Simple template for new commands.) 20f66f451Sopenharmony_ci * 30f66f451Sopenharmony_ci * Copyright 2012 Rob Landley <rob@landley.net> 40f66f451Sopenharmony_ci * 50f66f451Sopenharmony_ci * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ 60f66f451Sopenharmony_ci * See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html 70f66f451Sopenharmony_ci * See https://www.ietf.org/rfc/rfc3.txt 80f66f451Sopenharmony_ci * See http://man7.org/linux/man-pages/dir_section_1.html 90f66f451Sopenharmony_ci 100f66f451Sopenharmony_ciUSE_HELLO(NEWTOY(hello, 0, TOYFLAG_USR|TOYFLAG_BIN)) 110f66f451Sopenharmony_ci 120f66f451Sopenharmony_ciconfig HELLO 130f66f451Sopenharmony_ci bool "hello" 140f66f451Sopenharmony_ci default n 150f66f451Sopenharmony_ci help 160f66f451Sopenharmony_ci usage: hello 170f66f451Sopenharmony_ci 180f66f451Sopenharmony_ci A hello world program. 190f66f451Sopenharmony_ci 200f66f451Sopenharmony_ci Mostly used as a simple template for adding new commands. 210f66f451Sopenharmony_ci Occasionally nice to smoketest kernel booting via "init=/usr/bin/hello". 220f66f451Sopenharmony_ci*/ 230f66f451Sopenharmony_ci 240f66f451Sopenharmony_ci#define FOR_hello 250f66f451Sopenharmony_ci#include "toys.h" 260f66f451Sopenharmony_ci 270f66f451Sopenharmony_ciGLOBALS( 280f66f451Sopenharmony_ci int unused; 290f66f451Sopenharmony_ci) 300f66f451Sopenharmony_ci 310f66f451Sopenharmony_civoid hello_main(void) 320f66f451Sopenharmony_ci{ 330f66f451Sopenharmony_ci xprintf("Hello world\n"); 340f66f451Sopenharmony_ci 350f66f451Sopenharmony_ci // Avoid kernel panic if run as init. 360f66f451Sopenharmony_ci if (getpid() == 1) wait(&TT.unused); 370f66f451Sopenharmony_ci} 38