#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
static char *runStatusFile = "/syscfg/etc/runStatusFile";
FILE *pFile = NULL;
char runCountStr[6]={0};
unsigned runCountInt = 0;
char runTimeStr[6]={0};
unsigned runTimeInt = 0;
void doTask()
{
pFile = fopen(runStatusFile, "r+");
fseek (pFile, 6L, SEEK_SET);
fread (runTimeStr, sizeof(char), 5, pFile);
runTimeInt = atoi(runTimeStr);
runTimeInt += 10;
fseek (pFile, 6L, SEEK_SET);
sprintf(runTimeStr,"%d",runTimeInt);
fwrite(runTimeStr, sizeof(char),5, pFile);
//fseek (pFile, 6L, SEEK_SET);
//fread (runTimeStr, sizeof(char), 5, pFile);
//printf("runTimeStr = %s\n",runTimeStr);
fclose(pFile);
}
int main()
{
pFile = fopen(runStatusFile, "r+");
if(pFile == NULL)
{
pFile = fopen(runStatusFile,"w+");
fseek (pFile, 0L, SEEK_SET);
fwrite("0", sizeof(char), 1, pFile);
fseek (pFile, 6L, SEEK_SET);
fwrite("0", sizeof(char), 1, pFile);
}
fseek (pFile, 0L, SEEK_SET);
fread (runCountStr, sizeof(char), 5, pFile);
runCountInt = atoi(runCountStr);
runCountInt++;
sprintf(runCountStr,"%d",runCountInt);
fseek (pFile, 0L, SEEK_SET);
fwrite(runCountStr, sizeof(char), 5, pFile);
fclose(pFile);
struct sigaction act;
union sigval tsval;
act.sa_handler = doTask;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
sigaction(50, &act, NULL);
while(1)
{
sleep(10); //˯Ãß10Ãë
sigqueue(getpid(), 50, tsval);//ÏòÖ÷½ø³Ì·¢ËÍÐźţ¬Êµ¼ÊÉÏÊÇ×Ô¼º¸ø×Ô¼º·¢ÐźÅ
}
return 0;
1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......
ĿǰLAMP (Linux + Apache + MySQL + PHP) ½ü¼¸ÄêÀ´·¢Õ¹Ñ¸ËÙ£¬ÒѾ³ÉΪWeb ·þÎñÆ÷µÄÊÂʵ±ê×¼¡£LAMP
Õâ¸ö´ÊµÄÓÉÀ´×îÔçʼÓڵ¹úÔÓÖ¾“c't Magazine”£¬Michael KunzeÔÚ1990Äê×îÏȰÑÕâЩÏîÄ¿×éºÏÔÚÒ»Æð´´ÔìÁËLAMPµÄËõд×Ö¡£ÕâЩ×é¼þËäÈ»²¢²»ÊÇ¿ª¿ªÊ¼¾ÍÉè¼ÆÎªÒ»ÆðʹÓõ쬵«ÊÇ£¬ÕâЩ¿ªÔ´Èí¼þ¶¼¿ÉÒԺܷ½±ã µÄË ......