ÇÁ·Î±×·¡¹Ö

 3204, 153/161 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   kalon
   [C¾ð¾î] redefinition of struck flock ¿¡·¯

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=2771 [º¹»ç]


cslab:~/SystemSoftware(4)% gcc -o test ss.c
ss.c:7: error: redefinition of `struct flock'

ÇÑ ÆÄÀÏÀ» ÀÛ¾÷ÁßÀ϶§ ´Ù¸¥ °÷¿¡¼­ Á¢¼Ó ¸øÇÏ°Ô ¶ôÀ» °Å´Â ÇÁ·Î±×·¥À»
½Ã½ºÅÛ È£Ãâ??À» Çؼ­ ÇÏ´Â °Çµ¥¿ä
Çб³ Unix ¼­¹ö¿¡¼­ gcc ·Î ÄÄÆÄÀÏÇϴµ¥
ÀÌ·± ¿¡·¯°¡ ¶ß³×¿ä ¹öÀü ¹®Á¦¶ó°í º» °Í°°Àºµ¥
¾î¶»°Ô ÇØ°á ÇÒ ¼ö ÀÖÀ»±î¿ä?
Ȥ½Ã Äڵ忡 ¹®Á¦°¡ ÀÖ´Ù¸é ÄÚ¸àÆ® ºÎŹµå¸³´Ï´Ù.

------------------------------------------------------------------------------------------------


#include <fcntl.h>
#include <errno.h>
#define F_RDLCK 01/* read lock */
#define F_WRLCK 02/* write lock */
#define F_UNLCK 03/* release lock */
struct flock {
        short l_type; /* record locking type */
        short l_whence; /* same as lseek */
        long l_start; /* start of locked segment */
        long l_len; /* byte length of locked segment if 0, lock to EOF */
        short l_sysid;
        short l_pid;
        };
/* values for l_type */
int main(int argc, char *argv[])
{
        struct flock lock;
        int fd;
        char command[100];
                if ((fd = open(argv[1], O_RDWR)) == -1)
                {
                        perror(argv[1]);
                        exit(1);
                }
                lock.l_type = F_WRLCK;
                lock.l_whence = 0;
                lock.l_start = 0L;
                lock.l_len = 0L; /* whole file address space */
                if (fcntl (fd, F_SETLK, &lock) == -1)
                {
                        if (errno == EACCES)
                        {
                                printf("%s busy --try later\n", argv[1]);
                                exit(2);
                        }
                        else
                        {
                                perror(argv[1]);
                                exit(3);
                        }
      
                sprintf(command, "vi %s\n", argv[1]);
                system(command);
                lock.l_type = F_UNLCK; /* unlock file */
                fcntl(fd, F_SETLK, &lock);
                close(fd);
                exit(0);
}

  Hit : 5766     Date : 2010/11/22 04:19



    
blueh4g flock À̶ó´Â ±¸Á¶Ã¼ ¸íÀ» ´Ù¸¥°É·Î º¯°æÇØÁÖ¼¼¿ä. =) 2010/11/24  
blueh4g À§¿¡ »õ·Î Á¤¸³ÇϽŠflock ±¸Á¶Ã¼°¡ ¿ø·¡ Á¸ÀçÇÏ´Â ±¸Á¶Ã¼À̱⠶§¹®¿¡, »õ·Î ÀçÁ¤¸³Çϴµ¥¼­ »ý±â´Â ¿¡·¯ÀÔ´Ï´Ù~~ 2010/11/24  
kalon ¾Æ ±×·¸±º¿ä~ ´äº¯ °¨»çÇÕ´Ï´Ù.~~ 2010/11/26  
164   gcc ¿É¼Ç¿¡¼­ -static °ú -ggdb °¡ ÇÏ´Â ¿ªÇÒÀº?[3]     tinlove21
01/14 5767
163   [C ¾ð¾î] ¼Ò¼ö ã±â[1]     smile_mut
12/22 5777
162   gcj¿¡ °üÇؼ­ Áú¹®~[3]     bsshq7
10/29 5779
161   include & link Áú¹®Àä // c ¾ð¾î¿ä //[2]     tack7
12/18 5780
160     [re] ¸®´ª½º»ó DES¾Ë°í¸®Áò(C·Î ±¸¼º)..¾î¶»°Ô ÄÄÆÄÀÏ ÇÏ´ÂÁö...[4]     indra
10/06 5783
159     [re] ÆäÀÌÁö ·Îµù½Ã Áñ°Üã±â ÀÚµ¿À¸·Î Ãß°¡µÇ±âÁ» °¡¸£ÃÄ ÁÖ¼¼¿ä     ¼ÒÀ¯
09/13 5810
158   C¾ð¾î ¸»Àä..^^;[1]     canrose
09/06 5817
157   c ‘p°¡Áö ¸í·É¾îÁ» Áú¹®ÀÌ¿ä!![1]     darkstar12
09/04 5841
156   [ASP]ASP¿¡¼­ rs.open¿¡¼­ ¿À·ù°¡ ³ª³×¿ä[2]     Çܺ¸Ä­²ÊÂîÂÞ
12/03 5879
155   ¸®´ª½º ³×Æ®¿öÅ© ÇÁ·Î±×·¥ ¼Ò½ºÄÚµå ±¸ÇÏ°í ½ÍÀºµ¥¿ä.[1]     aiurchar
09/16 5896
154   ¾î¼Àºí¸®...[7]     µÎ·ç¹¶¼ú
02/28 5924
153     [re] C¾ð¾î ¸»Àä..^^;     ¼ÒÀ¯
09/12 5934
152     [re] c 몆°¡Áö ¸í·É¾îÁ» Áú¹®ÀÌ¿ä!![1]     indra
09/05 5962
151   [c¾ð¾î]vc 2010 error [c++ ÇÁ·ÎÁ§Æ®¿¡ intellisense ¹× °Ë»ö Á¤º¸ »ç¿ë ºÒ°¡]     goldbear564
01/20 5968
150   [c¾ð¾î] Å°,³ªÀÌ,¼ºº°ÀÔ·ÂÇϸé ÇÑÁÙ·Î ¶ß°ÔÇÒ·Á°íÇϴµ¥ ,, ¿¡·¯°¡..[3]     SKTCTO
03/25 5973
149   À©µµ¿ì ·Î¿ì ¼ÒÄÏ °ü·Ã Áú¹®ÀÔ´Ï´Ù..[2]     ¹Ùº¼ÀÌ
05/21 5989
148   ¾î¼Àºí¸®¾î, ±â°è¾î ¹è¿öº¸·Á°íÇϴµ¥¿ä ¤Ð[6]     hygasyde
01/24 6055
147   MFC ¸ÅÅ©·Î ¸¸µé±â Áú¹®![1]     musalhk
02/15 6058
146   win 32 api ·Î ¹ÂÁ÷Ç÷¹ÀÌ¾î ¸¸µé±â     khfs200
05/25 6060
145   cp¸í·É¾î ±¸ÇöÁßÀä À߸øµÈÁ¡Á» ÁöÀûÇØÁÖ¼¼¿ä[1]     hehesk
09/16 6063
[1]..[151][152] 153 [154][155][156][157][158][159][160]..[161]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org