Search code examples
macoskernel-extension

what the correct way to print my statements in no of times?


I write the code in the below manner but output prints in console only two times. Please friends help me

#include <mach/mach_types.h>
#include<libkern/libkern.h>

kern_return_t MyIntension_start(kmod_info_t * ki, void *d);

kern_return_t MyIntension_stop(kmod_info_t *ki, void *d);

kern_return_t MyIntension_start(kmod_info_t * ki, void *d)
{
    for(int i = 0 ;i < 10 ;i++)
    {
        printf("welcome to apple world\n");
    }
    return KERN_SUCCESS;
}


kern_return_t MyIntension_stop(kmod_info_t *ki, void *d)
{
    for(int i = 0 ;i < 10 ;i++)
    {
        printf("good bye to cruel apple world\n");
    }   
    return KERN_SUCCESS;
}

Solution

  • execute the same code two times then you get four lines.

    kern_return_t MyIntension_start(kmod_info_t * ki, void *d);
    
    kern_return_t MyIntension_stop(kmod_info_t *ki, void *d);
    
    kern_return_t MyIntension_start(kmod_info_t * ki, void *d)
    
    {
    
    for(int i = 0 ;i < 10 ;i++)
    {
    
    printf("welcome to apple world\n");
    
    
           }
    
    
    return KERN_SUCCESS;
    
    
    }
    kern_return_t MyIntension_stop(kmod_info_t *ki, void *d)
    
    {
    
    for(int i = 0 ;i < 10 ;i++)
    
    {
    
    printf("good bye to cruel apple world\n");
    
    }
    
    return KERN_SUCCESS;
    
    }