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 8770679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:36:15+00:00 2026-06-13T17:36:15+00:00

How to set an envirnoment variable from a process that will be visible by

  • 0

How to set an envirnoment variable from a process that will be visible by all processes?
I’m using C with Glib.

I have 10 processes that use the same library. The problem is that in that library a checking procedure (which is CPU hungry) is performed. I want to avoid that library checking procedure to be executed for every process. For the first process that is using the library it will be enough.

  • 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-13T17:36:17+00:00Added an answer on June 13, 2026 at 5:36 pm

    This is simply not possible.

    Setting an environment variable (or changing your current environment) is only visible from the children (and descendants) processes of your current process.

    Other processes, in particular the parent process (usually the shell running in the terminal where you start your program) are not affected.

    You might play dirty tricks like e.g. adding lines into $HOME/.bashrc etc. But you should not.

    You just need to document what environment variables are relevant. It is the user’s responsibility to set environment variables (perhaps by manually editing his $HOME/.bashrc etc etc). Leave that freedom to your user. Explain to him how to do that and why.

    You edited your question to explain that

    I have 10 processes that use the same library. The problem is that in that library a checking procedure ( which is CPU hungry ) is performed. I want to avoid that library checking procedure to be executed for every process.

    But you definitely should not need to change environment variable for that.

    You could

    1. decide and document that the checking is not performed, unless some particular environment variable (or some program argument) is given

    2. decide that the checking is given a particular file name, and use file locked write to write that file, and use file locked reads to read it again

    3. Have the checking write its result in some known in advance file, and read that file before deciding it you want to make the costly checks

    4. Have one process starting all the others, and inform them about the check (perhaps indeed setting some environment variable or some program argument) or use some Inter Process Communication trick to communicate with the others (you could use sockets, locked files, shared memory, etc etc…)

    5. Do many other tricks.

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

Sidebar

Related Questions

I need to set a system environment variable from a Bash script that would
I have installed Django on my host (I use their install version 1.1.1), all
I have a Jamfile that I am using with Boost.Python to wrap some C++
Background I have an app that I recently updated to Rails 3.2.1 (from Rails
I have a msi package generated by wix that creates a system environment variable
I use cwRsync to sync up some file from Windows to Ubuntu. This process
I need to set the an environment variable from within Perl. Ideally, I need
Is it possible to set environment variable with maven (OS: Linux)? I already have
How do I set environment variables from Java? I see that I can do
I am stuck on a issue. I am trying to set user-environment variables using

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.