From owner-freebsd-hackers Fri Jan 12 3:52:18 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from smtppop3pub.verizon.net (smtppop3pub.gte.net [206.46.170.22]) by hub.freebsd.org (Postfix) with ESMTP id AF2EF37B400 for ; Fri, 12 Jan 2001 03:52:00 -0800 (PST) Received: from chocolate (1Cust30.tnt1.san-jose2.ca.da.uu.net [63.59.129.30]) by smtppop3pub.verizon.net with SMTP for ; id FAA95764143 Fri, 12 Jan 2001 05:47:29 -0600 (CST) Message-ID: <001201c07c8d$4276f8a0$1e813b3f@netscaler.com> Reply-To: "Soumen Biswas" From: "Soumen Biswas" To: Subject: how to write custom init Date: Fri, 12 Jan 2001 03:46:08 -0800 Organization: Netscaler Inc. MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi , What are the points to be observed while writing custom init I am currently doing something like : /* 1. never exit 2. open fd 0,1 & 2 3. link statically */ int main( int argc, char **argv ) { int fd ; char cmd[128] = {0}; fd = open( "/dev/console", O_RDWR ); dup(fd); dup(fd); while( 1 ) { printf( "comm>" ); fflush( stdout ); fgets( cmd, sizeof(cmd ), stdin ); if( memcmp( "init", cmd , 4 ) == 0 ) { close(0); close(1);close(2); execv("/init/sbin", argv ); } if( memcmp( "quit", cmd, 4) == 0 ) reboot( RB_AUTOBOOT ); } /* while */ /* should not reach here */ return 0 ; } Am I missing something ? Thanx & Regards soumen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message