Linux2009. 6. 29. 18:04
*** glibc detected *** [filename+dir] : corrupted double-linked list: [0x%08X address] ***
라는 에러가 발생하고 죽는건, glibc에 추가된 메모리 보호기능이라는데

export MALLOC_CHECK_=0
으로 하면 출력도 안하고, 죽이지도 않는다고 한다.

[링크 : http://blog.daum.net/j020259/9927090]

glibc

    * Red Hat 엔터프라이즈 리눅스 4에 포함된 버전 glibc는 데이터 손상을 최대할 빨리 검색하여 방지할 수 있도록 내부 정상 감시 기능을 추가로 수행합니다. 데이터 손상이 감지되면 다음과 같은 메시지가 표준 오류로 나타날 것입니다 (만일 표준 오류(stderr)이 열려있지 않은 경우에는 syslog으로 기록됩니다):

      *** glibc detected *** double free or corruption: 0x0937d008 ***

      이 오류 메시지를 생성하는 프로그램은 디폴트로 제거(kill)됩니다; MALLOC_CHECK_ 환경 변수를 이용하여 오류 메시지 생성 여부를 선택하실 수 있습니다. 다음과 같은 설정이 가능합니다:

          o  0 ? 오류 메시지를 생성하지 않고, 프로그램을 제거하지 않음
          o  1 ? 오류 메시지를 생성하지만, 프로그램을 제거하지 않음
          o  2 ? 오류 메시지를 생성하지는 않지만, 프로그램은 제거함
          o  3 ? 오류 메시지를 생성하고 프로그램을 제거함

알림

      만일 MALLOC_CHECK_ 변수를 0이 아닌 다른 값으로 설정할 경우,
      glibc는 기본 설정 보다 광범위한 검사를 수행하므로결국 시스템 성능에 영향을 미칠 수 있습니다.

      만일 제삼자 ISV의 프로그램로 인해 이러한 데이터 손상 검사가 수행되고 오류 메시지가 나타난다면,
      심각한 문제일 수 있으니 어플리케이션의 제조업체에 보고하시기 바랍니다.


[링크 : http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/ko/release-notes/as-zseries/]


Posted by 구차니
Linux2009. 6. 19. 23:44
결국에는 어떤 값들을 처리해주고(tty 관련) 정도의 차이지
버퍼링 되는 것은 동일하고, 생각만큼 큰 차이는 없다고 한다.


일단 테스트 해본결과, canonical 입력의 우선순위가 더 높아 보였다.

#include "stdio.h"
#include "fcntl.h"
#include "sys/types.h"
#include "sys/stat.h"

void main() { char buf; // char buf[16]; int fd, ret;
fd = open("/dev/ttyS0", O_NOCTTY | O_NONBLOCK | O_RDWR); printf("fd[%08X]\n",fd);
while(1) { ret = read(fd, &buf, 1); // ret = read(fd, &buf, 10); if(ret > 0) printf("ret[%d] buf[%s]\n",ret,buf); }
}

위의 소스는 넌블러킹 모드로 하나의 문자를 받는 예제이다.
테스트 방법은
PC 1. 하이퍼터미널로 연결
PC 2. minicom 으로 연결
PC 2. 터미널에서 특정 포트 출력 (echo test string > /dev/ttyS0)
PC 2. 터미널에서 위의 프로그램 실행

sdfasfsadfsadfasfasfasfasfsadf

 CTRL-A Z for help |115200 8N1 | NOR | Minicom 2.3    | VT102 | Online 00:15

ret[-1] buf[▒]
ret[-1] buf[▒]
ret[-1] buf[▒]
ret[-1] buf[▒]
ret[-1] buf[▒]
ret[-1] buf[▒]
ret[-1] buf[▒]
ret[-1] buf[▒]

...

fd[00000003]
ret[1] buf[i]
ret[1] buf[ ]
ret[1] buf[a]
ret[1] buf[m]
ret[1] buf[ ]
ret[1] buf[a]
ret[1] buf[ ]
ret[1] buf[b]
ret[1] buf[o]
ret[1] buf[y]

...

ret[8] buf[this is ]
ret[10] buf[test strin]
ret[2] buf[g st strin]

테스트 1.
두개의 PC를 시리얼로 연결해 놓은 상태(canonical mode?)에서 다른 터미널에서
echo test string > /dev/ttyS0
명령을 수행하여 출력 :: 시리얼을 연채로 똑같은 포트를 또 열어서 출력 가능 함
(둘다 canonical mode로 추측됨)

테스트 2.
non-canonical mode로 터미널에서 키를 입력 받는 위의 소스코드를 실행하여,
원격지에서 하이퍼터미널로 키 입력을 받는지 테스트 함.
두개만 있을때에는 이상없이 작동

테스트 3.
테스트 2 상황에서 minicom을 실행시킴
 ret[-1] buf[▒]
이런식으로 에러가 발생하고 키를 입력 받을 수 없음.

테스트 4.
위의 상황에서 minicom 종료 함.
이상없이 메시지 받을 수 있음.

테스트 5.
반대로 minicom을 구동한 상황에서 소스코드를 실행시킴
메시지를 받을 수 없음 (minicom 쪽이 우선적으로 메시지 받을 수 있음)

테스트 6.
한 바이트씩 받지 않고 10바이트씩 받는 테스트,
하이퍼터미널에 10글자 정도의 문장을 복사하여 한번에 붙여 넣었는데 10글자를 한번에 받지 못하고
이상하게 받아 들이게 됨. non-blocking 에서는 되도록이면 한 문자씩 버퍼에 받아야 할 듯 함.

결론: canonical 입력은 non-canonical 보다 우선적으로 받을 수 있는 것으로 보임.
       캐노니컬 / 넌캐노니컬과는 상관없이 블러킹 / 넌-블러킹 연관이고
       블러킹이 넌-블러킹 보다 우선적으로 보내고/받을 수 있는 것으로 보임.

[링크 : http://stackoverflow.com/questions/358342/canonical-vs-non-canonical-terminal-input]
Posted by 구차니
Linux2009. 6. 19. 23:12
일반적으로 많이 사용하는 리다이렉션은

>  - 파일에 저장(새로파일 생성)
<  - 파일에서 불러옴
|  - 파이프라인, 결과를 이어줌
>> - 파일에 저장(기존파일에 이어서 붙임)
이정도이고, 잘 사용되지는 않지만 유용한 것으로는

2>  - 에러만 파일에 저장
정도가 있다.
>는 stdout 만 리다이렉션해서 화면으로는 에러가 출력되고
2>는 stderr 만 리다이렉션해서 화면으로는 정상 메시지가 출력된다.

둘다 리다이렉션해서 파일로 저장하고 싶다면

2>&1
이렇게 하면 된다.
예를 들어 컴파일시 모든 메시지를 저장하고 싶다면
$ make install 1> err.log 2>&1
라고 하면 된다.

> word
    The standard output (file descriptor 1) is sent to the file word which is created if it does not already exist.

>> word

    The standard output is sent to file word. If the file exists then output is appended (by seeking to the end); otherwise the file is created.

< word

    The standard input (file descriptor 0) is taken from the file word.

<< word

    The standard input is taken from the lines of shell input that follow up to but not including a line consisting only of word. If word is quoted then no interpretation of the document occurs. If word is not quoted then parameter and command substitution occur and \ is used to quote the characters \ $ ` and the first character of word. In the latter case \newline is ignored (c.f. quoted strings).

>& digit

    The file descriptor digit is duplicated using the system call dup (2) and the result is used as the standard output.

<& digit

    The standard input is duplicated from file descriptor digit.

<&-

    The standard input is closed.

>&-

    The standard output is closed.

[링크 : http://www.partmaps.org/era/unix/shell.html]

<&Digit      Duplicates standard input from the file descriptor specified by the Digit parameter
>& Digit     Duplicates standard output in the file descriptor specified by the Digit parameter
<&-          Closes standard input
>&-          Closes standard output
<&p          Moves input from the co-process to standard input
>&p          Moves output to the co-process to standard output

[링크 : http://www.softpanorama.org/Scripting/Shellorama/input_and_output_redirection.shtml]

Posted by 구차니
Linux2009. 6. 19. 23:05
콘솔 메시지 막기

커널 부트 옵션에 quite 를 넣어주면, dmesg 쪽으로 나가는 것은 버퍼링 쌓이지만,
화면으로 출력이 되지 않아, 부팅시 약간의 속도 향상을 기대 할 수 있다고 한다.

[링크 : http://elinux.org/Disable_Console]




시리얼 포트로 콘솔 메시지 출력하기

/etc/inittab
/boot/grub/grub.conf
/boot/grub/menu.lst 파일을 수정해야 한다. 수정 부분이 많으므로 링크 참조

kernel /vmlinuz-2.6.9-42.0.10.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n

[링크 : http://www.cyberciti.biz/faq/linux-serial-console-howto/]
Posted by 구차니
Linux2009. 6. 19. 20:47
커널소스를 분석해 보진 않아서 정확하게 어떻게 여는지는 모르겠지만,
아마 tty 특성상 canonical mode로 여는것으로 보인다.

/dev/console is a symbolic link to /dev/tty0, and the kernel regards /dev/tty0 as a synonym for the current VT. XFree86 1.3 changes the owner of /dev/tty0, but does not reset this after finishing. Thus, loadkeys or dumpkeys might fail because someone else owns /dev/tty0; in such a case you might run X first. Note that you cannot change keyboard mappings when not at the console

[링크 : http://www.faqs.org/docs/Linux-HOWTO/Keyboard-and-Console-HOWTO.html]

Posted by 구차니
Linux2009. 6. 19. 20:35
$ sudo apt-get install manpages-dev

한가지 신기한 건, 페도라에서는 open이 3p에 있었는데 우분투는 2에 있다.


[링크 : http://mcchae.egloos.com/6956190]
Posted by 구차니
Linux2009. 6. 19. 18:21
이런 기능이 있는지도 몰랐는데..

Ctrl-S는 일시정지
Ctrl-Q는 일시정지 풀기 란다.


[링크 : http://nomoreid.egloos.com/1079123]
Posted by 구차니
Linux2009. 6. 18. 21:15
Posted by 구차니
Linux2009. 6. 10. 19:38
$ diff -urN ori_dir modified_dir > patch.diff

       -u     Use the unified output format.
       -r     When comparing directories, recursively compare any subdirectories found.
       -N
       --new-file
              In directory comparison, if a file is found in only one directory, treat it as present but  empty  in  the
              other directory.

일반적으로 GNU 프로젝트의 패치로 사용하는 옵션이라고 한다.
-u는 unified 포맷 출력
-r은 디렉토리 비교
-N은 새 파일이 있을시 없는쪽은 비어있는 파일로 간주하고 비교함
 간단하게 전부 내용이 추가된걸로 표시된다. 이러한 옵션 없이 diff하면 아래와 같이 빈 파일이 출력된다.
 Only in linux-2.6.17.14_stm22_0039_STFAE: .config2

하지만 -N 옵션을 넣으주면 아래와 같이 출력이 된다.
diff -urN linux-2.6.17.14_stm22_0039_STFAE_ORI/.config2 linux-2.6.17.14_stm22_0039_STFAE/.config2
--- linux-2.6.17.14_stm22_0039_STFAE_ORI/.config2       1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.17.14_stm22_0039_STFAE/.config2   2008-09-12 12:32:23.000000000 +0900
@@ -0,0 +1,1312 @@
+#
+# source code ...



[링크 : http://wiki.kldp.org/wiki.php/DiffAndPatch]
Posted by 구차니
Linux2009. 6. 9. 22:14
Sysfs is a virtual file system provided by Linux 2.6. Sysfs exports information about devices and drivers from the kernel device model to userspace, and is also used for configuration. It's similar to sysctl mechanism found in BSD systems, but implemented as a file system instead of a separate mechanism.

Sysfs is designed to export the information present in the device tree which would then no longer clutter up procfs.

Sysfs and userspace
Sysfs is used by several utilities to access information about hardware and its driver (kernel modules) such as udev or HAL. Scripts have been written to access information previously obtained via procfs, and some scripts configure device drivers and devices via their attributes.




2.6 kernel 부터 지원되는 녀석으로, proc filesystem에 지원되지 않는 것들을 지원하기 위한 것이다.
mount 하기 위해서는(되어있지 않았다면)
 $ mount -t sysfs sysfs /sys
를 실행해주면 /sys에 마운트 된다.


그리고 sysfs의 정보를 읽기 위해서는 udevinfo를 이용하여 쿼리를 날려주면 된다.
 $ udevinfo -a -p /dev/sda
위의 명령어는 sda의 정보를 보는 예제

[sysfs : http://en.wikipedia.org/wiki/Sysfs]
[udevinfo : http://linux.die.net/man/8/udevinfo]

'Linux' 카테고리의 다른 글

Linux 시리얼 프로그래밍 - 한글 번역본  (0) 2009.06.18
diff 로 patch 파일 만들기  (0) 2009.06.10
ifconfig --help  (0) 2009.06.09
dhcp 작동중인지 확인하는 방법  (0) 2009.06.09
ip 관련 정보 얻어내기  (2) 2009.06.09
Posted by 구차니