更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
init.c 文件参考

浏览源代码.

函数

int main (int argc, char *const *argv)
 

函数说明

◆ main()

int main ( int  argc,
char *const *  argv 
)

在文件 init.c49 行定义.

50{
51 (void)argv;
52 int ret;
53 pid_t gid;
54 const char *shellPath = "/bin/mksh";
55
56#ifdef LOSCFG_QUICK_START
57 const char *samplePath = "/dev/shm/sample_quickstart";
58
59 ret = fork();
60 if (ret < 0) {
61 printf("Failed to fork for sample_quickstart\n");
62 } else if (ret == 0) {
63 (void)execve(samplePath, NULL, NULL);
64 exit(0);
65 }
66
67 usleep(WAIT_FOR_SAMPLE);
68
69 int fd = open("/dev/quickstart", O_RDONLY);
70 if (fd != -1) {
71 ioctl(fd, QUICKSTART_INITSTEP2);
72 close(fd);
73 }
74#endif
75 ret = fork();
76 if (ret < 0) {
77 printf("Failed to fork for shell\n");
78 } else if (ret == 0) {
79 gid = getpgrp();
80 if (gid < 0) {
81 printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
82 exit(0);
83 }
84 ret = tcsetpgrp(STDIN_FILENO, gid);
85 if (ret != 0) {
86 printf("tcsetpgrp failed, errno %d\n", errno);
87 exit(0);
88 }
89 (void)execve(shellPath, NULL, NULL);
90 exit(0);
91 }
92
93 while (1) {
94 ret = waitpid(-1, 0, WNOHANG);
95 if (ret == 0) {
96 sleep(1);
97 }
98 };
99}
void exit(int status)
Definition: stdlib.c:60
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void
unsigned int sleep(unsigned int seconds)
Definition: time.c:1086
int usleep(unsigned long useconds) int usleep(unsigned useconds)
Definition: time.c:1060
函数调用图: