1

I have this small piece of code on emacs org-mode :

#+BEGIN_SRC C :eval
#+BEGIN_SRC C :fork-example1.c :noweb no-export :eval :flags -Wall -Werror -pedantic
//Fork-exemplec-cours.c
#include <stdio.h>
#include <unistd.h> // pour fork
int main()
{
    int i = 0;
    printf("Before fork, %d\n", i);
    fork();
    printf("After fork, %d\n", ++i);
    return 0;
}
#+END_SRC

And the result is the following:

#+RESULTS:
| Before fork | 0 |
| After fork  | 1 |
| Before fork | 0 |
| After fork  | 1 |

As you see there is an issue because I should have :

#+RESULTS:
| Before fork | 0 |
| After fork  | 1 |
| After fork  | 1 |

The most surprising is that I look for /tmp/babel-5930pB/ and I execute vince@debianvs:/tmp/babel-5930pB/$ ./C-bin-BbVB44

I have exactly this :

Before fork, 0
After fork, 1
After fork, 1

Can you help me..... I can't understand why I have this behaviour in org-mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.