📄 pcs_startup.c
字号:
/*
* File name : Pcs_Startup.c
* Purpose : Startup necessary
* Author : Mr. Zhujingkun
* Date Created : 200004,01
* Version : Version 1.0
* Environment : SCO UNIX 5.0.5
* Portability : UNIX Platform
* Warnings : no
* Called Functions: When system startup
*/
#include "stdlib.h"
#include "stdio.h"
#include "unistd.h"
#include "Pcs_Startup.h"
#include "my_api.h"
void main()
{
char cProcessFullPathName[MAX_LINE_LEN+1]; //Name with the full path
char cProcessName[MAX_LINE_LEN+1]; //Not contain path information
char cCommand[500], cDescription[500];
FILE *hProcList;
int iRet; //Return value of fork()
int iCurrNumber; //Record the current Process position during the whole
sprintf( cCommand, "rm %s\n", STARTUP_PROCESS_ID_LIST );
system( cCommand );
hProcList = fopen( STARTUP_PROCESS_LIST, "r" );
if( hProcList == NULL )
{
sprintf( cDescription, "Cc_Startup.x: Cannot open file: %s,The file may not exist!", STARTUP_PROCESS_LIST);
ErrorLog( cDescription );
exit(-1);
}
iCurrNumber=0;
while( myapi_ReadALine( cProcessFullPathName, hProcList ) )
{
if( cProcessFullPathName[0] == '#' ) continue;
if( cProcessFullPathName[0] == NULL ) continue;
//Now I find a ProcessName(with the full path)
GetArgv0( cProcessName, cProcessFullPathName );
iRet = fork();
if( iRet == 0 ) //I'm child
{
//The process forked has no argument.
execl( cProcessFullPathName, cProcessName, NULL );
exit(0);
}
else if( iRet == -1 ) //Error, cannot create process
{
ErrorLog( "LOG_ERROR: Pcs_Startup.x: Cannot create sub_process: YSSMFile!\n" );
}
else //iRet is the child Process ID, I'm in parent.
{
ProcIDLog(iRet);
printf("The Process ID of %s is: %i\n", cProcessName, iRet);
}
iCurrNumber++;
if(iCurrNumber >= TOTAL_PROCESS_NUMBER ) break;
}
fclose( hProcList );
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -