Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linux api±Ê¼Ç£¨7£©£ºÏµÍ³µ÷ÓÃÈçºÎ°ÚÍÑÐźŵĸÉÈÅ

ÔÚlinux»·¾³Ï±à³ÌÓÐÒ»¸öºÜÈÃÈËÍ·ÌÛµÄÎÊÌâ¾ÍÊÇÐźŶÔϵͳµ÷ÓõĸÉÈÅ£¬ÔÚϵͳµ÷Óùý³ÌÖÐÈç¹ûÊܵ½ÐźŵĸÉÈÅ£¬
²¿·Öϵͳµ÷ÓûὫerrnoÉèÖóÉEINTR£¬ÎÒÃDz»µÃ²»±àдÏÂÃæµÄ´íÎó´¦Àí´úÂëÀ´·ÀÖ¹ÕâÖÖÇé¿öµÄ·¢Éú£º
syscall:
int ret = syscall(...);
if (ret < 0 && EINTER == errno)
goto syscall;
else if(ret < 0)
...
else
... 
Ò»´ÎÓÖÒ»´ÎµÄ±àдµÄ»°ÕæµÄºÜ·³£¬¶øÇ°¶Ëʱ¼äÎÒÔÚchromeµÄÔ´´úÂëÖÐÕÒµ½µÄÒ»¶Î´úÂëÕýºÃ½â¾öÁËÕâÖÖ³óªµÄ±àÂ룺
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#define HANDLE_EINTR(x) ({ \
typeof(x) __eintr_code__; \
do { \
__eintr_code__ = x; \
} while(__eintr_code__ < 0 && EINTR == errno); \
__eintr_code__; \
})
int main()
{
int fd = 0;
char buf[1024];
fd = open("hello world", O_RDWR);
HANDLE_EINTR(read(fd,buf, sizeof(buf)));
close(fd);
return 0;
}
 
µ±È»ÎÒÃÇÒ²²»ÊÇÖ»ÒªÅöµ½ÏµÍ³µ÷ÓþÍʹÓÃHANDLE_EINTR£¬Ò»¸öϵͳµ÷Óú¯ÊýÖÁÉÙÒªÂú×ãÁ½¸öÌõ¼þµÄʱºò²ÅÄÜʹÓãº
1£©·µ»ØÖµÀàÐÍΪint
2£©»áÊܵ½ÐźŵĸÉÈÅ£¬Ò²¾ÍÊÇ˵ÓпÉÄܽ«errnoÉèÖóÉEINTR£¨Õâ¾ÍÐèÒªÎÒÃDzémanÊÖ²áÁË£©¡£ÉÏÃæµÄopenº¯Êý¾Í
²»»áÊܵ½ÐźŵĸÉÈÅ£¬ËùÒԾͲ»ÄÜʹÓÃÕâ¸öºê¡£
ÖÁÉÙµ½Ä¿Ç°ÎªÖ¹£¬ÎÒ·¢ÏÖ·²ÊÇÄܹ»½«errnoÉèÖóÉEINTRµÄϵͳº¯ÊýµÄ·µ»ØÖµÀàÐͶ¼ÊÇint£¬²¢ÇÒµ±³ö´íµÄʱºò
·µ»ØֵСÓÚ0¡£


Ïà¹ØÎĵµ£º

LinuxϽâѹѹËõ¼°´ò°üÃüÁî´óÈ«


LinuxϽâѹѹËõ¼°´ò°üÃüÁî´óÈ«
[ÈÕÆÚ£º2008-11-04]
À´Ô´£º  ×÷Õߣºjenen
 
———————————————
.tar
½â°ü£ºtar xvf FileName.tar
´ò°ü£ºtar cvf FileName.tar DirName
£¨×¢£ºtarÊÇ´ò°ü£¬²»ÊÇѹËõ£¡£©
&mdas ......

linux api±Ê¼Ç£¨3£©£ºỊ̈߳¨Ò»£©

±¾ÎÄÖн«½²Êölinux»·¾³±à³ÌÖÐÏ̵߳ÄʹÓᣲ»Ëµ·Ï»°Ö±½ÓÉÏ´úÂ룺
#include <pthread.h>
#include <assert.h>
struct ThreadData
{
int i;
};
void * ThreadProc(void* arg)
{
ThreadData* data = static_cast<ThreadData*>(arg);
//do something

pthread_exit(data);
}
int main() ......

LinuxÏ zip ºÍ unzipµÄÓ÷¨

     zipÃüÁîµÄ»ù±¾Ó÷¨ÊÇ£ºzip [²ÎÊý] [Îļþ1] [Îļþ2]
      ¼òµ¥µÄÀý×Ó£º
      °Ñ±¾Ä¿Â¼ÏµÄtestÎļþ´ò°ü³Étest.zipÎļþ£ºzip test.zip test/* £¬Èç¹ûÔÚÎļþÖÐÓþø¶ÔµÄ·¾¶£¬ÄÇôÔÚѹËõÎļþÖÐÒ²ÊǾø¶Ô·¾¶¡£¾ÍÊÇ˵£¬Èç¹ûÄã zip test.zip /hom ......

linuxÃüÁîÔ´ÂëµÄ²é¿´

ÔÚƽ³£µÄ×÷ÒµÖУ¬ÓÐʱºòÀÏʦÈÃ×Ô¼ºÊµÏÖÖîÈçcatµÈÀàµÄ³ÌÐò£¬ÓÐʱºò½ÐÓÃshellʵÏÖ£¬ÓÐʱºòÓÃcʵÏÖ£¬µ«ÊÇÎÒ¾­³£Ò»µãÍ·Ð÷¶¼Ã»ÓУ¬²»¹ýÎÒÏëµ½linux¿ªÔ´µÄ£¬ÃüÁî´úÂë¿ÉÒÔÄÃÀ´²Î¿¼Ï°¢£¬ËùÒÔÎÒ¾ÍÏë¿´¿´linuxÃüÁîµÄÔ´´úÂ룬ÓÚÊǾͿªÊ¼Á˰ڶɹ·¹·µÄËÑË÷¹ý³Ì¡£´Ó½á¹ûÀ´¿´£¬ÓÐÁ½ÖÖÇé¿ö£¬Ò»ÖÖÊǸøÓèrpmµÄ°üµÄÐÎʽ£»ÁíÒ»ÖÖÊÇ»ùÓÚdeb°üµÄÐ ......

Linux ½ø³Ìµ÷¶È»úÖÆ

ÓÅÏÈȨֻÊǵ÷¶ÈËã·¨¿¼ÂǵÄÒ»¸ö·½Ãæ
½ø³Ìµ÷¶ÈÒÀ¾Ý
µ÷¶È³ÌÐòÔËÐÐʱ£¬ÒªÔÚËùÓпÉÔËÐÐ״̬µÄ½ø³ÌÖÐÑ¡Ôñ×îÖµµÃÔËÐеĽø³ÌͶÈëÔËÐС£Ñ¡Ôñ½ø³ÌµÄÒÀ¾ÝÊÇʲôÄØ£¿ÔÚÿ¸ö½ø³ÌµÄtask_struct½á¹¹ÖÐÓÐÒÔÏÂËÄÏpolicy¡¢priority¡¢counter¡¢rt_priority¡£ÕâËÄÏîÊÇÑ¡Ôñ½ø³ÌµÄÒÀ¾Ý¡£ÆäÖУ¬policyÊǽø³ÌµÄµ÷¶È²ßÂÔ£¬ÓÃÀ´Çø·Öʵʱ½ø³ÌºÍÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ