<div dir="ltr">Hello,<div><br></div><div>When I try to execute the following code, I always run into errors. Can someone help me.</div><div><br></div><div>Code:</div><div><br></div><div><div>int lttng_init() {</div><div>        int err;</div><div>        int l_fd = -1;</div><div><br></div><div>        if(0 != system("mkdir /tmp/mk_lttng")) {</div><div>                printf("Directory exists\n");</div><div>        }</div><div><br></div><div>        setenv("LTTNG_HOME", "/tmp/mk_lttng", 1);</div><div>        fprintf(stderr, "LTTNG_HOME is %s\n",getenv("LTTNG_HOME"));</div><div><br></div><div>        l_fd = open("/tmp/lttng_test.lck", O_CREAT | O_WRONLY | O_EXCL, 0644);</div><div>        err = errno;</div><div><br></div><div>        if(l_fd != -1) {</div><div>                fprintf(stderr, "Creating lock file l_fd = %d\n", l_fd);</div><div>                if(0 != system("lttng destroy -a")) {</div><div>                        return -1;</div><div>                }</div><div><br></div><div>                if(0 != system("lttng create")) {</div><div>                        return -1;</div><div>                }</div><div><br></div><div>                if(0 != system("lttng enable-event -u -a")) {</div><div>                        return -1;</div><div>                }</div><div><br></div><div>                if(0 != system("lttng start")) {</div><div>                        return -1;</div><div>                }</div><div><br></div><div>        }</div><div>        else {</div><div>                fprintf(stderr, "Unable to get lock err = %d\n",err);</div><div>                // Someone has already created a session. We just dump into their buffer</div><div>        }</div><div>}</div></div><div><br></div><div><br></div><div>int main() {</div><div>        if( -1 == lttng_init())</div><div>            assert(0);</div><div>}</div><div><br></div><div>When I compile and run the above code, I am getting these errors.</div><div><br></div><div><div>cycl01:~/hello-tp% ./hello</div><div>mkdir: cannot create directory `/tmp/mk_lttng': File exists</div><div>Directory exists</div><div>LTTNG_HOME is /tmp/mk_lttng</div><div>Creating lock file l_fd = 4</div><div>Spawning a session daemon</div><div>I/O warning : failed to load external entity "/usr/share/xml/lttng/session.xsd"</div><div>XML Error: Failed to locate the main schema resource at '/usr/share/xml/lttng/session.xsd'.</div><div>Error: XSD parsing failed</div><div>Error: Session load failed: Invalid session configuration</div><div>No session found, nothing to do.</div><div><b>PERROR - 09:20:36.889067 [7142/7150]: bind inet: Address already in use (in lttcomm_bind_inet_sock() at inet.c:109)</b></div><div><b>Warning: Another session daemon is using this JUL port. JUL support will be deactivated to prevent interfering with the tracing. </b></div></div><div><b><br></b></div><div><b>I am trying to run multiple of these programs in parallel</b>. So I am trying to incorporate a locking mechanism so that only one instance succeeds and creates the session, and other instances just dump into the existing session. </div><div><br></div><div>Thanks</div><div>Chid</div></div>