Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:51:33+00:00 2026-06-11T10:51:33+00:00

#include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h> char a[]=Hello; void * thread_body(void *

  • 0
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>

char a[]="Hello";

void * thread_body(void * param) {
        while(1)
                printf("%s\n", param);
}

int main(int argc,  char *argv[]) {
        pthread_t threadHello;
        int code;
        pthread_create(&threadHello,  NULL,  thread_body,  a);
        pthread_cancel(threadHello);
        pthread_exit(0);
}

When I compile and run this under Solaris 10 (SunOS 5.10), it doesn’t stop. But under Linux it works as intended.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:51:34+00:00Added an answer on June 11, 2026 at 10:51 am

    Per POSIX, printf (and all of stdio) may be a cancellation point. It is not required to be. I suspect Solaris just doesn’t choose to make it one. Have you tried another function like sleep here?

    If you really need printf to be cancellable, you’ll probably need to implement your own printf-like function as a wrapper for dprintf, but that won’t work so well if you’re depending on the builtin locking functionality of stdio..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> void wrapperPrint(char* s) { printf(s); return; } int main() { wrapperPrint(Hello world\n);
#include<stdio.h> #include<stdlib.h> char* re() { char *p = hello; return p; } int main()
#include <stdio.h> #include <stdlib.h> int main(void) { int x; int *in, *begin; in =
#include<stdio.h> #include<math.h> int main(int argc, char **argv){ // read in the command-line argument double
#include <stdio.h> #include <pthread.h> #include <time.h> #include <stdlib.h> typedef struct pr_struct{ int owner; int
Here is the code #include<stdio.h> #include<sys/types.h> #include<stdlib.h> #include<pthread.h> typedef struct std_thread { char name[20];
This is my code: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> int num_mezzo_1(int
I have the following code: #include <stdlib.h> #include <stdio.h> #include <pthread.h> #define NUM_THREADS 100
#include <pthread.h> #include <stdio.h> #include <unistd.h> #include <vector> #include <string> #include <iostream> FILE* fp;
I written this code: #include <stdio.h> #include <pthread.h> void* cuoco(void* arg) { fprintf(stderr,Inizio codice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.