Search Results

Search found 4 results on 1 pages for 'yakup ozden'.

Page 1/1 | 1 

  • Creating multiple process and simulation in C via fork()

    - by Yakup OZDEN
    i want to create multiple process groups which will call different functions. i write the code below. firstly i want to get following output ./fork 4 5 I am a child: 1 PID: 22330 I am a child2: 1 PID: 22334 I am a child: 2 PID: 22331 I am a child2: 5 PID: 22338 I am a child: 4 PID: 22333 I am a child: 3 PID: 22332 I am a child2: 2 PID: 22335 I am a child2: 4 PID: 22337 I am a child2: 3 PID: 22336 ' #include <stdio.h> #include <stdlib.h> #include <unistd.h> void forkChildren (int nChildren) { int i; pid_t pid; for (i = 1; i <= nChildren; i++) { pid = fork(); if (pid == -1) { /* error handling here, if needed */ return; } if (pid == 0) { printf("I am a child: %d PID: %d\n",i, getpid()); sleep (5); wait(NULL); return; } } } void forkChildren2 (int nChildren) { int i; pid_t pid; for (i = 1; i <= nChildren; i++) { pid = fork(); if (pid == -1) { /* error handling here, if needed */ return; } if (pid == 0) { printf("I am a child2: %d PID: %d\n",i, getpid()); sleep (2); return; } } } the code gives me the output [ozdeny@hyperion ~]$ ./fork 4 5 I am a child: 1 PID: 22330 I am a child: 2 PID: 22331 I am a child: 3 PID: 22332 I am a child: 4 PID: 22333 I am a child2: 1 PID: 22334 I am a child2: 2 PID: 22335 I am a child2: 4 PID: 22337 I am a child2: 5 PID: 22338 [ozdeny@hyperion ~]$ I am a child2: 3 PID: 22336 I am a child2: 1 PID: 22339 I am a child2: 2 PID: 22340 I am a child2: 3 PID: 22341 I am a child2: 4 PID: 22342 I am a child2: 5 PID: 22343 I am a child2: 1 PID: 22345 I am a child2: 2 PID: 22346 I am a child2: 3 PID: 22347 I am a child2: 1 PID: 22349 I am a child2: 2 PID: 22350 I am a child2: 1 PID: 22344 I am a child2: 2 PID: 22352 I am a child2: 3 PID: 22353 I am a child2: 4 PID: 22354 I am a child2: 5 PID: 22355 I am a child2: 3 PID: 22351 I am a child2: 4 PID: 22356 I am a child2: 5 PID: 22357 I am a child2: 4 PID: 22348 I am a child2: 5 PID: 22358

    Read the article

  • how to configure jetty 7 to use syslog or log4j

    - by egemen ozden
    I am looking for a way to direct all the jetty 7 logging to syslog. My current configuration dumps everything to JETTY_HOME/logs/.. After some initial ivestigation, it seems I should change JETTY_HOME/etc/jetty-logging.xml, but this does not look straightforward. It looks like I should create a new PrintStream implementation which sends its output to syslog and redirecting stderr and stdout to that class in jetty-logging.xml. any easier way to do that or to make jetty log directly to log4j ? Thanks

    Read the article

  • Why ((Integer) weightModel.getObject()).intValue(); throws exception

    - by yakup
    I am learning Wicket by "Enjoying Web Development with Wicket" book. And in an example: int weight = ((Integer) weightModel.getObject()).intValue(); is used. When I click Submit button it throws exception. But after changed the code to: int weight=Integer.parseInt( (String) weightModel.getObject()); It works fine. What is the reason for throwing the exception? The full code: GetRequest.java package myapp.postage; import java.util.HashMap; import java.util.Map; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.Model; @SuppressWarnings("unchecked") public class GetRequest extends WebPage { private Model weightModel=new Model(); private Model patronCodeModel=new Model(); private Map patronCodeToDiscount; public GetRequest(){ patronCodeToDiscount=new HashMap(); patronCodeToDiscount.put("p1", new Integer(90)); patronCodeToDiscount.put("p2", new Integer(95)); Form form=new Form("form"){ @Override protected void onSubmit(){ int weight = ((Integer) weightModel.getObject()).intValue(); Integer discount=(Integer)patronCodeToDiscount.get(patronCodeModel.getObject()); int postagePerKg=10; int postage=weight*postagePerKg; if(discount!=null){ postage=postage*discount.intValue()/100; } ShowPostage showPostage=new ShowPostage(postage); setResponsePage(showPostage); } }; TextField weight=new TextField("weight",weightModel); form.add(weight); TextField patronCode=new TextField("patronCode",patronCodeModel); form.add(patronCode); add(form); } } The html file GetRequest.html: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <form wicket:id="form"> <table> <tr> <td>Weight</td> <td><input type="text" wicket:id="weight"/></td> </tr> <tr> <td>Patron code:</td> <td><input type="text" wicket:id="patronCode"/></td> </tr> <tr> <td></td> <td><input type="submit"/></td> </tr> </table> </form> </html>

    Read the article

  • how to configure jetty 7 to use syslog or log4j

    - by egemen ozden
    I am looking for a way to direct all the jetty 7 logging to syslog. My current configuration dumps everything to JETTY_HOME/logs/.. After some initial ivestigation, it seems I should change JETTY_HOME/etc/jetty-logging.xml, but this does not look straightforward. It looks like I should create a new PrintStream implementation which sends its output to syslog and redirecting stderr and stdout to that class in jetty-logging.xml. any easier way to do that or to make jetty log directly to log4j ? Thanks

    Read the article

1