linux에서 동일 프로세스가 있는지 확인

njy0504의 이미지

linux에서 동일프로세스 명이 있는지를 check 할려고 합니다

/proc/ 의 readdir 한 ->d_name 으로

open(/proc/dirp->d_name)을 열어서

prpsinfo_t retval;

if( ioctl(fd,PIOCPSINFO,&retval)!=-1) 하여

retval.pr_psargs 와 찾을려는 process 명을 비교할려고 합니다

linux에서는 PIOCPSINFO 이 선언되어 있지 않다고 하네요
실제 /usr/include 밑에서 찾아봐도 없구요

부탁드립니다.. linux에서 /proc에 대한 정보를 알수 있는 방법을 알려주십시요

systemV 계열( sun) 에서는 잘 되지만 linux에서는 안 됩니다

질문이 너무 어렵나? 아무도 읽어만 보시고 답은 안해주시네요?

리눅스에서 같은 프로세스가 존재하면 안 될경우에는 꼭 찾아 봐야 하자나요?..

hanzo69의 이미지

named mutex를 만드셔서...
그 이름의 뮤텍스가 이미 존재하는가를 확인하면 될텐데요...
동일한 인스턴스가 존재하는가를 확인할 때 플랫폼과는 무관하게 일반적으로 많이 쓰는 방법인데요..

님ㅎ 즐~

njy0504의 이미지

그 방법에 대해서 참고할 만한 곳이 없습니까?

너무 rough 하네요.. 좀더 자세한 것은 알 수 없나요?/

그렇게는 한번도 쓰 본적이 없어서요

익명 사용자의 이미지

named mutex는 system 전체에서 같은 이름을 가진 mutex를 오직 하나만 말들 수 있습니다. 이미 같은 이름의 mutex가 생성되어 있으면 생성이 안됩니다.

그러니까 single instance를 보장해야 할 경우 프로그램 초기화 과정에서 특정명의 named mutex를 생성합니다. 이때 생성에 성공하면 이 프로그램은 아직 실행한 적이 없는 것이겠지요. 생성에 실패했다면 이미 이 프로그램이 실행되어 있다는 것이니까 바로 종료해버리면 됩니다.

litdream의 이미지

세마포어도 괜찮겠죠?

삽질의 대마왕...

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.